Page 1 of 1 1
Topic Options
#121615 - 2004-06-22 10:14 AM Offline Folder Settings
Michael_French Offline
Just in Town

Registered: 2004-06-22
Posts: 2
Does anyone know how to read/write the offline folder settings for shares on Windows Server 2003?

I have managed to enumerate the shares using the following:

Code:
 
$objWMI = GetObject("winmgmts:{impersonationlevel=impersonate}!//" + $Server)
$shareList = $objWMI.ExecQuery("select * from win32_share where type=0")



I would like to be able to set these shares to not allow users to mark the data for offline use (a new feature of Win2k3).

thanks,
Michael.

Top
#121616 - 2004-06-22 03:55 PM Re: Offline Folder Settings
Rory Daniels Offline
Getting the hang of it

Registered: 2003-02-25
Posts: 64
Loc: Bristol, UK
Here's an example of getting a setting an Environment Setting using WMI on a remote PC.

Try using Microsoft WMI Object Browser to discover what fields are in the returned value. Microsoft WMI Tools

Code:
 Function WMIEnvironmentSetting($hostname,$ENV,$Value,$Type)
? "Function WMISetEnvironmentSetting:"
? " ($hostname, $ENV, $Value, $Type)" ?
Select
Case $type = "set"
$WMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\$hostname\root\cimv2")
If @ERROR <> 0
? " Error connecting to WMI interface"
$WMIEnvironmentSetting = 1
?
Exit
Else
? " WMI interface connection successfull"
$EnvironmentCommands = $WMIService.ExecQuery("Select * from Win32_Environment Where Name = '$ENV'")
If @ERROR <> 0
? " Error connecting to Win32_Environment "
$WMIEnvironmentSetting = 1
?
Exit
Else
? " Win32_Environment connection complete"
For Each $EnvironmentCommand in $EnvironmentCommands
? " Current Setting: " + $EnvironmentCommand.VariableValue
$EnvironmentCommand.VariableValue = $Value
If @ERROR <> 0
? " Cannot set Environment Setting for $env"
$WMIEnvironmentSetting = 1
?
Exit
Else
$EnvironmentCommand.put_
If @ERROR <> -2147352573
? " Cannot set Environment Setting for $env"
$WMIEnvironmentSetting = 1
?
Exit
Else
? " Environment Setting for $env set to: " + $EnvironmentCommand.VariableValue
$WMIEnvironmentSetting = 0
EndIf

EndIf
Next
EndIf
EndIf
?
Case $type = "Get"
$WMI=GetObject("winmgmts:{impersonationLevel=impersonate}!\\$hostname\root\cimv2")
$Items=$WMI.ExecQuery("Select * from Win32_Environment Where Name = '$ENV'")
For Each $Item in $Items
? $WMIEnvironmentSetting=$Item.VariableValue
Next
EndSelect
EndFunction


Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1376 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.052 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org