Hi guys, Powershell newbie here.
I am working at a simple PowerShell script which checks for some shares, and creates them if they aren't there. Should be simple, but I cannot get it to work.
Here is the code:
I get:
Unexpected token '{' in expression or statement.
At :line:5 char:59
+ If (!(GET-WMIOBJECT Win32_Share -filter name=Config) { <<<<
If I do not check for shares, but simply create them, there is no problem.
I am working at a simple PowerShell script which checks for some shares, and creates them if they aren't there. Should be simple, but I cannot get it to work.
Here is the code:
Code:
#Load WIN32_share class for creating shares. Place it in $Shares variable
$Shares=[WMICLASS]WIN32_Share
#Create Config share if it isn't already there
If (!(GET-WMIOBJECT Win32_Share -filter name=Config) {
$Shares.Create("c:\test\Config",Config,0)
}
I get:
Unexpected token '{' in expression or statement.
At :line:5 char:59
+ If (!(GET-WMIOBJECT Win32_Share -filter name=Config) { <<<<
If I do not check for shares, but simply create them, there is no problem.
