Getting Started with Service Manager Cmdlets for Windows PowerShell: Create $Profile #sysctr
Every time you start a Windows PowerShell session to run a Service Manager cmdlet, you must first add the Service Manager Windows PowerShell snap-in. As most of us are lazy admins I created a “service manager” profile having all Service Manager cmdlets by default available when starting PowerShell session.
Create a profile
- Before we decide to create a profile, let’s check to see whether we already have one:
Test-Path $profile
- If the profile exists this command will return True; if it doesn’t exist, the command will return False. If this command returns False, you need to create the profile.
New-Item -path $profile -type file -force
We pass three parameters to New-Item:
- -path $profile We’re passing the full path, stored in the $profile variable, of the item we want to create.
- -type file This tells New-Item what type of item we’re creating, in this case a file.
- -force This parameter tells New-Item to create the full path and file no matter what.
Now you can open the profile and take a look:
notepad $profile
- Copy the following code and close notepad.
Set-ExecutionPolicy RemoteSigned
Add-PSSnapIn SMCmdletSnapIn
Get-Command –pssnapin -SMCmdletSnapin
- When starting a PowerShell session Service Manager cmdlet’s are automatically loaded including a List of the Service Manager Cmdlets.
Perhaps very simple but useful…
Some additional Service Manager PowerShell resources:
Service Manager and PowerShell
CodePlex Project: Service Manager PowerShell cmdlets
Creating PowerShell Cmdlets for Service Manager
Sources:
Categories