Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Command "Get-ChildItem IIS:\Sites" causes an error

$
0
0

Hi!

Simple script shown below causes an exception on my computer:

Import-Module WebAdministration
Get-ChildItem IIS:\Sites

---

powershell -NonInteractive .\test.ps1 Get-ChildItem : Could not load file or assembly 'Microsoft.PowerShell.Commands.Management' or one of its dependencies. The system cannot find the file specified. At C:\...\test.ps1:3 char:1+ Get-ChildItem IIS:\Sites+ ~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : NotSpecified: (:) [Get-ChildItem], FileNotFoundException+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.GetChildItemCommand

But if I add Write-Host at the beginning of the script it works fine:

Write-Host '!!!'
Import-Module WebAdministration
Get-ChildItem IIS:\Sites

Unfortunately, I have no idea what may cause this problem...


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>