AnupDharia
AnupDharia

Reputation: 21

Powershell command to export IIS websites and app pools of a remote server

I have the command which exports websites of the current logged in server (as below). I need the command to export websites of a different server.

%windir%\system32\inetsrv\appcmd list site /config /xml > c:\websites.xml

Upvotes: 1

Views: 10666

Answers (1)

Avner
Avner

Reputation: 4556

try with Invoke-Command

Note the syntax you have is for a dos command. The following should get you on track. Of course there is credentials you may have to pass in.

Remoting must be enabled on the remote servers Run Enable-PSRemoting -Force on each server.

Invoke-Command -Computer remoteserver -ScriptBlock { 
    & $Env:Windir\system32\inetsrv\appcmd.exe list site /config /xml
} | Out-File c:\websites.xml -Append

Note that the 'powershell' way of getting sites as powershell objects is shown here: https://stackoverflow.com/a/25091831/1165140

Upvotes: 3

Related Questions