Default WebServiceEndpoint value for SMA Cmdlets

When using the Cmdlets of the Service Management Automation (SMA) PowerShell module, all actions are targeted against a SMA Web Service and therefore have a required parameter called WebServiceEndpoint. If you’re kinda stressed out by repetitively typing this parameter value, you can define a default parameter value in your Windows PowerShell session to set the value automatically. For example, in your PowerShell profile script, use the following command to set the default value for the WebServiceEndpoint parameter for all related SMA Cmdlets:

Hello again. This time I will share a small function that resides in my PowerShell profile script: grep. What is grep? grep is a text search utility originally written for Unix. The command name is an abbreviation for “global regular expression print”. The original grep – and my PowerShell grep function as well – searches files for lines matching a given regular expression and displays the matches in standard output.

Here comes the ready for use function…

grep

PowerShell

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

functiongrep(

$File=$(throw'Empty value for the File parameter.'),

$Pattern=$(throw'Empty value for the Pattern parameter.'),

[switch]$Recurse

){

if($Recurse){

$Files=@(Get-ChildItem$File-Recurse)

}else{

$Files=@(Get-ChildItem$File)

}

if($Files.Count-eq0){

Write-Host"File(s) not found - $File";return$null

}

$Results=$Files|Select-String-Pattern$Pattern

if(!$Results){

Write-Host"No matches found in $File";return$null

}

$Results|Format-ListFileName,LineNumber,Line

}

Actually the grep function simplifies the usage of a command line like below: