Something I’ve learned: a quick way to access your ConfigMgr cmdlets is awesome 🙂
Now that’s not so hard to achieve, place the following function in your PowerShell profile.
(A great guide to the profile over at How-To Geek)
1 2 3 4 5 6 |
Function Load-CM { Set-Location ‘D:Program FilesMicrosoft Configuration ManagerAdminConsolebin’ Import-Module .ConfigurationManager.psd1 Set-Location A01: } |
Now all we have to do is call the Load-CM to have some fun.
Create IP Range Boundaries
I had one task that I kept doing multiple times, to create new IP Range Boundaries.
Then I found a really nice function at CM12SDK.net, and after some small modifications it was fit for the job.
I didn’t wanna write Site Code and Site Server for every new boundary, so I simply hardcoded them instead. And yes, it’s OK to be lazy.
In order to save some extra time (be extra lazy) I added the new boundary to the default boundary group.
Now it’s fast and easy 🙂
New-IPRangeBoundary -DisplayName “Range 007” -Value “192.168.7.2-192.168.7.17”
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 |
Function New-IPRangeBoundary { [CmdLetBinding()] PARAM( [Parameter(Mandatory = $True, HelpMessage = "Please enter Boundary Display name")] $DisplayName, [Parameter(Mandatory = $True, HelpMessage = "Please enter Boundary value")] $Value ) $SiteServer = 'Site Server' $Arguments = @{DisplayName = $DisplayName; BoundaryType = 3; Value = $Value} Try{ Set-WmiInstance -Namespace "RootSMSSite_A01" -Class SMS_Boundary -Arguments $Arguments -ComputerName $SiteServer -ErrorAction STOP $BoundaryID = Get-WmiObject -Namespace "RootSMSSite_A01" -Class SMS_Boundary -Filter "DisplayName = '$DisplayName'" | select BoundaryID $BoundaryGroup = "Default Boundary Group" $BoundaryGroupQuery = Get-WmiObject -Namespace "RootSMSSite_A01" -Class SMS_BoundaryGroup -Filter "Name = '$BoundaryGroup'" $BoundaryGroupQuery.AddBoundary($BoundaryID.BoundaryID) Write-Host -ForegroundColor Green 'Boundary created!' } Catch{ $_.Exception.Message } } |
List you’re Boundaries
Now that you’ve hopefully created some boundaries, maybe you’ll want to list them as well?
Here is a simple function to do that:
Get-IPBoundaries
1 2 3 4 5 6 |
Function Get-IPBoundaries { $SiteServer = 'Site Server' Get-WmiObject -Namespace "RootSMSSite_A01" -Class SMS_Boundary -ComputerName $SiteServer -ErrorAction STOP | select BoundaryID,DisplayName,Value| sort Displayname | ft -AutoSize } |
/Andreas
Great post! We will be linking to this particularly great post on our website.
Keep up the great writing.