Can't run PowerShell IIS Snap-in script
powershell noob here, please bear me.
i have simple powershell script. when run script management console, completes without error :
ps iis:\> $sitename=get-childitem iis:\sites -name
ps iis:\> echo $sitename
brandapi
ddbservices
ddbweb
faatestharness
when save script, fails run:
ps iis:\> powershell d:\temp\test.ps1
get-childitem : cannot find drive. drive name 'iis' not exist.
@ d:\temp\test.ps1:1 char:14
+ get-childitem <<<< iis:\sites -name
+ categoryinfo : objectnotfound: (iis:string) [get-childitem], drivenotfoundexception
+ fullyqualifiederrorid : drivenotfound,microsoft.powershell.commands.getchilditemcommand
i tried dotsource it, still doesn't help. seems issue being in iis namespace , calling script path?
help please!
why running as powershell d:\temp\test.ps1
just run as
d:\temp\test.ps1
this might because loading new powershell process , might not have snapin added.
looks snapin loaded in current session, might want add part of script.
import-module webadministration
Windows Server > Windows PowerShell
Comments
Post a Comment