Trying to automate ftp site manipulation on IIS7.5, through powershell, but I can't start the ftp site. Everything else, so far, I succeeded.
PS IIS:\Sites> Get-ChildItem | Where {$_.Name -eq "FtpData"}
Name ID State Physical Path Bindings
---- -- ----- ------------- --------
FtpData 3 Stopped D:\Services\_Empty ftp *:80:
PS IIS:\Sites> Start-WebSite -Name "FtpData"
Start-WebSite : The object identifier does not represent a valid object. (Exception from HRESULT: 0x800710D8)
At line:1 char:1
+ Start-WebSite -Name "FtpData"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Website], COMException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.IIs.PowerShell.Provider.StartWebsiteCommand
This issue is address in technet "Starting / Stoping an FTP site using PowerShell... IIS 7.5 on 2008R2" but is has three years old.
Using the appcmd has the same issue:
C:\Users\myself>c:\Windows\system32\inetsrv\appcmd start site FtpData
ERROR ( hresult:800710d8, message:Command execution failed.
The object identifier does not represent a valid object.
)
This article FTP on IIS 7 on Server Core indicates to start it from the UI Console, but that means it can't be automated.
Has any one got a solution to this?
Stumbled upon this through Powershell autocomplete and turned out working on Server 2012 R2:
$ftpSite = IIS:\Sites\FtpData
$ftpSite.ftpServer.Start()
The $ftpSite... did not work for me. I also found the below to be neater.
To Start:
(get-Website -Name "myftpsite").ftpserver.start()
To Stop:
(get-Website -Name "myftpsite").ftpserver.stop()
Source: https://peter.hahndorf.eu/blog/iisftp.html (Forever Breathes The Lonely Word - Peter Hahndorf on software IIS - Managing FTP sites with PowerShell)
User contributions licensed under CC BY-SA 3.0