Skip to content

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.
  • Creating a profile is really easy. Simply type this at the command prompt:
  •  

    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:

    http://technet.microsoft.com/en-us/library/ff461183.aspx

    http://technet.microsoft.com/en-us/library/ee692764.aspx

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out /  Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out /  Change )

    Connecting to %s

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    %d bloggers like this: