Although PowerShell has been around for 10 years now, there are still some who are just getting started with it. There are several categories that new comers fit into, some are just starting out in their career, others may be career changers, and others may have been in the industry for a number of years and are finally trying to embrace PowerShell.
Regardless of which category you fit into, I'll be presenting a session on "PowerShell Fundamentals for the Absolute Beginner" at SQL Saturday #515 Read more [...]

I recently ran into a problem with the PowerShell like operator that I wanted to share since what's occurring may not be immediately apparent.
The like operator allows for comparison tests of strings using wildcard characters instead of exact matches. I think of it being similar to the match operator except like uses simple wildcards instead of regular expressions.

PowerShell

1

'Microsoft Windows 10 Enterprise'-like'*Windows 10*'

Easy enough, right? A string on the left and another string with wildcards on the right. If Read more [...]

Whether or not your place of employment requires that your cellphone be placed on silent or not while in the office, it's simply a common courtesy to prevent interruptions and distractions to your co-workers when your twenty-seven different social media, email, phone, voicemail, and shopping applications that are installed on your phone constantly chime or play your favorite song every thirty seconds.
The problem is, who can remember to silence their phone after arriving in the office before Read more [...]

A couple of weeks ago I published a blog article "PowerShell function for creating a script module template" and I thought I would follow-up that article with the same type of function for creating a PowerShell function template. Instead of having to remember things like checking to make sure an approved verb is used, that a Pester test is created, and comment based help is entered in the right format, a template such as the one shown in the following code example can make your life much simpler.

New-MrFunction

PowerShell

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

#Requires -Version 3.0 -Modules Pester

functionNew-MrFunction{

<#

.SYNOPSIS

Creates a new PowerShell function in the specified location.

.DESCRIPTION

New-MrFunction is an advanced function that creates a new PowerShell function in the

specified location including creating a Pester test for the new function.

.PARAMETER Name

Name of the function.

.PARAMETER Path

Path of the location where to create the function. This location must already exist.

I received notification last Friday, July 1st that I've been renewed for another year as a Microsoft MVP. This is my third MVP award, two as a PowerShell MVP and now one as a Cloud and Datacenter MVP.
Although I'm now considered a Cloud and Datacenter MVP due to the changes to the Microsoft's MVP program, my focus is still PowerShell. I look forward to seeing my fellow MVP's at the MVP Summit again later this year.
In addition to being a multiyear recipient of the Microsoft MVP award, I'm Read more [...]

I'm curious to know what process others use to create new PowerShell script modules?
Since the initial process of creating a PowerShell script module seems redundant and tedious, I decided to create a function that creates a template for new script modules that I create which includes creating both the script module PSM1 and manifest PSD1 files and filling in the information that I would normally include:

New-MrScriptModule

PowerShell

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

functionNew-MrScriptModule{

<#

.SYNOPSIS

Creates a new PowerShell script module in the specified location.

.DESCRIPTION

New-MrScriptModule is an advanced function that creates a new PowerShell script module in the

specified location including creating the module folder and both the PSM1 script module file

and PSD1 module manifest.

.PARAMETER Name

Name of the script module.

.PARAMETER Path

Parent path of the location to create the script module in. This location must already exist.

.PARAMETER Author

Specifies the module author.

.PARAMETER CompanyName

Identifies the company or vendor who created the module.

.PARAMETER Description

Describes the contents of the module.

.PARAMETER PowerShellVersion

Specifies the minimum version of Windows PowerShell that will work with this module. For example,

I’m presenting a session on Building Unconventional SQL Server Tools in PowerShell this weekend at SQL Saturday #498 in Chattanooga.
Ever had records from a SQL Server database table come up missing? Maybe someone or some process deleted them, but who really knows what happened to them? Wouldn’t it be awesome to create a free tool with PowerShell that automates the task of sifting through the transaction log backups and even the active transaction log to determine when deletes occurred Read more [...]

I decided to update the one liner from my blog article last week and take it a step further by turning it into a reusable tool that displays information about module updates that are available regardless of where they were installed from.

Find-MrModuleUpdate

PowerShell

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

#Requires -Version 3.0 -Modules PowerShellGet

functionFind-MrModuleUpdate{

<#

.SYNOPSIS

Finds updates for installed modules from an online gallery that matches the specified criteria.

.DESCRIPTION

Find-MrModuleUpdate is a PowerShell advanced function that finds updates from an online gallery for locally installed modules

regardless of whether or not they were originally installed from an online gallery or from the same online gallery where the

update is found.

.PARAMETER Name

Specifies the names of one or more modules to search for.

.PARAMETER Scope

Specifies the search scope of the installed modules. The acceptable values for this parameter are: AllUsers and CurrentUser.

As shown in the previous results, the function lists modules that have updates available regardless of where they were originally installed from. It also lists the installed version and location Read more [...]

There are PowerShell modules that ship with Windows 10 that weren't installed from the PowerShell Gallery using PowerShellGet so they can't be updated using the Update-Module cmdlet. This also applies for any modules that you've installed manually yourself.
The following PowerShell script retrieves a list of the most recent version of the modules in the all users path for PowerShell modules. It determines which ones weren't installed using PowerShellGet based on the hidden xml file that would Read more [...]

I'm presenting a session on PowerShell Desired State Configuration from the Trenches this weekend at SQL Saturday #491 in Pensacola.
There are lots of things to consider when configuring systems in your on-premises datacenters with Desired State Configuration depending on what the state of your current environment is, whether or not DSC will be configured to apply and monitor or apply and autocorrect configuration drift, and whether or not you’ll be using push or pull configuration mode. Read more [...]

I presented a session on PowerShell Toolmaking with Advanced Functions and Script Modules this past weekend at SQL Saturday #521 in Atlanta. I decided to make an attempt to record my session which was presented live in front of a packed room full of attendees:
The recording turned out very well considering I used the built-in laptop microphone and I moved around during my presentation. The audio levels have been tweaked because they were often too low depending on how far away I was from Read more [...]

I'll be presenting a session on PowerShell Toolmaking with Advanced Functions and Script Modules this weekend at SQL Saturday #521 in Atlanta.
Transitioning from writing PowerShell one-liners and basic scripts to creating reusable PowerShell tools with advanced functions and script modules can be a daunting task and with all the different ways that you’ll find on the Internet to accomplish the same task, it can definitely seem overwhelming. During this session, PowerShell MVP Mike F Robbins Read more [...]

We've all heard that TDD (Test Driven Development) means that you write unit tests before writing any code. Most of us are probably writing functional or acceptance tests after the fact because the idea of Test Driven Development isn't clearly defined, at least not in my opinion. I originally thought it meant to write thorough unit tests to test all functionality for a specific piece of code such as a PowerShell function from start to finish before writing any of the production code for the function Read more [...]

I briefly mentioned and demonstrated something similar to this at the end of one of my sessions at the PowerShell and DevOps Global Summit 2016. Since then, I've tested more which has led to a better solution.
We've all been taught that it's best practice to use a #Requires statement in our functions that specifies the required PowerShell version along with any module dependencies, but following this best practice has one unexpected side effect when dot-sourcing functions in PS1 files from a PSM1 Read more [...]

I recently wrote a Pester test that performs some basic operational validation (smoke tests) of SQL Servers. I've previously written similar tests as functions as shown in my "Write Dynamic Unit Tests for your PowerShell Code with Pester" blog article, but I decided to write this one as a script with the naming convention that seems to be recommended. The name of this particular test is "Validate-MrSQLServer.Tests.ps1". You're probably thinking "Validate" isn't an approved verb and you're right, Read more [...]

Links

My Guest Blog Articles

User Groups

Disclaimer

All data and information provided on this site is for informational purposes only. Mike F Robbins (mikefrobbins.com) makes no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this site and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use. All information is provided on an as-is basis.