On our old server 2003 server I had the following code that would remotely share a folder and set its permissions.
Now on server 2008 r2 its not working and I can't figure out why
$FILE_SHARE=0
$MAXIMUM_CONNECTIONS=-1
$objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $datacomp & "\root\cimv2:Win32_Process")
$Locator=ObjCreate("WbemScripting.SWbemLocator")
$objWMIService = $Locator.ConnectServer($datacomp, "\root\CIMV2")
$objNewShare = $objWMIService.