I want to use appcmd with Invoke-Command in Powershell to add a virtual directory.
I am using reference from: 1) appcmd to create virtual directory 2) Powershell Invoke-Command
Here is the code snippet:
$appCmdCommand2 = [string]::Format(
{"appcmd.exe set config -section:system.applicationHost/sites /+"[name='Default Web Site'].[path='/'].[path='/MyWebsite/dev',physicalPath='{0}']" /commit:apphost"},$folderName)
Invoke-Command -ComputerName ComputerAA -ScriptBlock {$appCmdCommand2}
When I run the code above, I keep getting error saying:
Unexpected token 'name='Default Web Site'].[path='/'].[path='/MyWebsite/dev'' in expression or statement.
I am new to Powershell and I have been searching everywhere how to solve this problem.
If anyone could show me how to correct my Powershell snippet so I could create a virtual directory? Thank you