Calling STSADM from within a PowerShell script

For various SharePoint admin tasks, there are times when you need to execute an STSADM command from within a PowerShell script. 

Before you can do that, you’ll need to tell PowerShell where to find STSADM executable. You can do that by adding the following line to your profile.ps1 file (usually located in C:\WINDOWS\system32\windowspowershell\v1.0 ):

Set-Alias -Name stsadm -Value $env:CommonProgramFiles”\Microsoft Shared\Web Server Extensions\12\BIN\STSADM.EXE”

Now you can use stsadm in your scripts and it should work beautifully…

Advertisements

2 Responses to “Calling STSADM from within a PowerShell script”


  1. 1 htaiyebi February 22, 2010 at 4:02 pm

    Andre,

    Question about profile.ps1
    where this file should be located – currently it is located in
    c:\Windows\System32\WindowsPowerShell\v1.0\Examples

    should this file be @
    c:\Windows\System32\WindowsPowerShell\v1.0\

    Secondly the stsadm path line can added as one line in profile.ps1
    Set-Alias -Name stsadm -Value $env:CommonProgramFiles”\Microsoft Shared\Web Server Extensions\12\BIN\STSADM.EXE”

    ——
    and how to add the STSADM command in the ps script
    Following is my STSADM Command
    stsadm -o backup -directory \\backup_server\SPBackups\SSPBackup -backupmethod full -item SharedServices1

    Please can you help and guide me to create the new powershell script (this is my first ps script

    Thank you
    Taiyebi


  1. 1 Running STSADM from within PowerShell « red1'sharepointspace Trackback on August 21, 2012 at 8:01 pm

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s




RSS Information Week Headlines

  • An error has occurred; the feed is probably down. Try again later.

RSS SharePoint Team Blog

  • An error has occurred; the feed is probably down. Try again later.

RSS InfoPath Team Blog

  • An error has occurred; the feed is probably down. Try again later.

RSS Joel Oleson Blog

  • An error has occurred; the feed is probably down. Try again later.

RSS Susan Hanley’s KM Blog

  • An error has occurred; the feed is probably down. Try again later.

Blog Stats

  • 348,120 hits

%d bloggers like this: