I'm trying to automation some IIS configuration using the webadministration module. I can see from using Get-PSDrive that it has loaded successfully--however, I can't interact with it in any way. I can't see content or set my location to the drive.
PS C:\> import-module WebAdministration PS C:\> Get-PSDrive Name Used (GB) Free (GB) Provider Root CurrentLocation ---- --------- --------- -------- ---- --------------- Alias Alias C 8.96 0.00 FileSystem C:\ Cert Certificate \ D FileSystem D:\ Env Environment HKCU Registry HKEY_CURRENT_USER HKLM Registry HKEY_LOCAL_MACHINE IIS WebAdminis... \\CITLBLDEMO04 [...]
PS C:\> iis: set-location : Cannot find path 'IIS:\' because it does not exist. At line:1 char:1+ set-location IIS:+ ~~~~~~~~~~~~~~~~~+ CategoryInfo : ObjectNotFound: (IIS:\:String) [Set-Location], ItemNotFoundException+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand PS C:\> cd iis: cd : Cannot find path 'IIS:\' because it does not exist. At line:1 char:1+ cd iis:+ ~~~~~~~+ CategoryInfo : ObjectNotFound: (IIS:\:String) [Set-Location], ItemNotFoundException+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand PS C:\> Get-ChildItem -Path IIS:\ Get-ChildItem : Cannot find path '\\CITLBLDEMO04\' because it does not exist. At line:1 char:1+ Get-ChildItem -Path IIS:\+ ~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : ObjectNotFound: (\\CITLBLDEMO04\:String) [Get-ChildItem], ItemNotFoundException+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
I'm using 64-bit Powershell v5.0 on Windows 10. On my Windows 7 machine with Powershell v4.0, this doesn't appear to be a problem.
Even join-path won't work if it involves the IIS PSDrive path--I get a NullReferenceException because it can't find that part of the path.
$localsite = 'www1' $path = join-path -path IIS:\Sites -ChildPath $localsite
produces
join-path : Object reference not set to an instance of an object. At line:1 char:9+ $path = join-path -path IIS:\Sites -ChildPath $localsite+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : NotSpecified: (:) [Join-Path], NullReferenceException+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.JoinPathCommand
Thoughts?