Using powershell i am stopping IIS web site
function GoOffLine([psobject] $obj)
{
Invoke-Command -ComputerName $obj.ComputerName -ScriptBlock {import-module WebAdministration; Stop-Website 'My-Website'}
Start-Sleep -Seconds 3
WriteMessage("Application is offline.")
}
The above script works fine as long as i have Web site name hard-coded in the script. However when i change the script and pass the web site name using variable i get error
function GoOffLine([psobject] $obj)
{
Invoke-Command -ComputerName $obj.ComputerName -ScriptBlock {import-module WebAdministration; Stop-Website $obj.WebsiteName}
Start-Sleep -Seconds 3
WriteMessage("Application is offline.")
}
Error
Cannot validate argument on parameter 'Name'. The argument is null. Provide a valid value for the argument, and then try running the command again.