I am using the following command in PowerShell 2.0 to check if the particular folder is shared or not but I am getting an error.
[bool](Get-WmiObject -Class Win32_Share -ComputerName ravenPC -Filter "Path='D:\websites\website1'")
Also, I want to store the value of bool in a variable and check it each time if it's true or false. Can someone help me on this.
The error I get is as follows:
Get-WmiObject : Invalid query At line:1 char:21 + [bool](Get-WmiObject <<<< -Class Win32_Share -ComputerName ravenPC -Filter "Path='D:\websites\website1'") + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
if(Get-WmiObject -Class Win32_Share | Select-String -pattern "yourFolder"){ echo "Is Shared"; }
– Hackerman