Folder share permission to wmi class
-
Monday, May 14, 2012 10:13 AM
Hi !
I'm coming to you because I need help to one script !
I'm trying to get all the Folder shared and them permission and to push the result into Wmi class.
this is my script
# Create Hash Table $Arguments = @{} # Getting WMI Objects $PartagesE = "IPC$" $path = @(get-wmiobject win32_share | Get-acl ) # Create SCCM_Folder_Share WMI Class Remove-WmiObject SCCM_Folder_Share -ErrorAction SilentlyContinue $newWMIObject = New-Object System.Management.ManagementClass $newWMIObject.Name = "SCCM_Folder_Share" $newWMIObject.Properties.add("Share_Folder_Status", "") $newWMIObject.Properties.item("Share_Folder_Status").Qualifiers.Add("Key", $true) $newWMIObject.Put() # Write Bitlocker Status into the WMI SCCM_Bitlocker Repository Set-WmiInstance -Class SCCM_Folder_Share -Argument $Arguments # Create SCCM_Folder_Share WMI Class Remove-WmiObject SCCM_Folder_Share -ErrorAction SilentlyContinue $newWMIObject = New-Object System.Management.ManagementClass $newWMIObject.Name = "SCCM_Folder_Share" $newWMIObject.Properties.add("Folder", "") $newWMIObject.Properties.add("Path", "") $newWMIObject.Properties.add("Permission", "") $newWMIObject.Properties.add("Date", "") $newWMIObject.Put() # For each drive in Bitdrive process drive(s) Foreach ($Folder in $path) { if ($ParagesE -notcontains $Partages) { $Arguments.Add("Folder" , ($Folder).Path) $Arguments.Add("Path" , ($Folder).Directory) $Arguments.Add("Permission" , ($Folder).Access) #$Arguments.Add("Date" , (Date)) } # Write Bitlocker Status into the WMI Folder_Share Repository Set-WmiInstance -Class SCCM_Folder_Share -Argument $Arguments # Clear Hash table $Arguments.Clear() } # End Check if Bitstatus is $nullbut I have the following error :
Exception calling "Put" with "0" argument(s): "Access denied " At C:\Users\guillaume.verrey\Desktop\IDMF_Share_Permission\Share_permission_script_v2.ps1:39 char:18 + $newWMIObject.Put <<<< () + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException Set-WmiInstance : Not found At C:\Users\guillaume.verrey\Desktop\IDMF_Share_Permission\Share_permission_script_v2.ps1:54 char:20 + Set-WmiInstance <<<< -Class SCCM_Folder_Share -Argument $Arguments + CategoryInfo : InvalidOperation: (:) [Set-WmiInstance], ManagementException + FullyQualifiedErrorId : SetWMIManagementException,Microsoft.PowerShell.Commands.SetWmiInstance
Please someone can help me ?
- Moved by Garth JonesMVP Saturday, November 17, 2012 9:47 PM No a CM07 Reporting question. (From:Configuration Manager 2007 Reporting)
All Replies
-
Monday, May 14, 2012 11:27 PM
This is not really a reporting issue, I would recommend post this to a PoSH forums you will get better response from PoSH MVP.
Try this forum
http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/threads
http://www.enhansoft.com/
- Proposed As Answer by Garth JonesMVP Saturday, June 09, 2012 9:14 PM
- Unproposed As Answer by Garth JonesMVP Saturday, November 03, 2012 9:31 PM
-
Saturday, November 17, 2012 10:16 PM
Hi !
I'm coming to you because I need help to one script !
I'm trying to get all the Folder shared and them permission and to push the result into Wmi class.
this is my script
# Create Hash Table $Arguments = @{} # Getting WMI Objects $PartagesE = "IPC$" $path = @(get-wmiobject win32_share | Get-acl ) # Create SCCM_Folder_Share WMI Class Remove-WmiObject SCCM_Folder_Share -ErrorAction SilentlyContinue $newWMIObject = New-Object System.Management.ManagementClass $newWMIObject.Name = "SCCM_Folder_Share" $newWMIObject.Properties.add("Share_Folder_Status", "") $newWMIObject.Properties.item("Share_Folder_Status").Qualifiers.Add("Key", $true) $newWMIObject.Put() # Write Bitlocker Status into the WMI SCCM_Bitlocker Repository Set-WmiInstance -Class SCCM_Folder_Share -Argument $Arguments # Create SCCM_Folder_Share WMI Class Remove-WmiObject SCCM_Folder_Share -ErrorAction SilentlyContinue $newWMIObject = New-Object System.Management.ManagementClass $newWMIObject.Name = "SCCM_Folder_Share" $newWMIObject.Properties.add("Folder", "") $newWMIObject.Properties.add("Path", "") $newWMIObject.Properties.add("Permission", "") $newWMIObject.Properties.add("Date", "") $newWMIObject.Put() # For each drive in Bitdrive process drive(s) Foreach ($Folder in $path) { if ($ParagesE -notcontains $Partages) { $Arguments.Add("Folder" , ($Folder).Path) $Arguments.Add("Path" , ($Folder).Directory) $Arguments.Add("Permission" , ($Folder).Access) #$Arguments.Add("Date" , (Date)) } # Write Bitlocker Status into the WMI Folder_Share Repository Set-WmiInstance -Class SCCM_Folder_Share -Argument $Arguments # Clear Hash table $Arguments.Clear() } # End Check if Bitstatus is $nullbut I have the following error :
Exception calling "Put" with "0" argument(s): "Access denied " At C:\Users\guillaume.verrey\Desktop\IDMF_Share_Permission\Share_permission_script_v2.ps1:39 char:18 + $newWMIObject.Put <<<< () + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException Set-WmiInstance : Not found At C:\Users\guillaume.verrey\Desktop\IDMF_Share_Permission\Share_permission_script_v2.ps1:54 char:20 + Set-WmiInstance <<<< -Class SCCM_Folder_Share -Argument $Arguments + CategoryInfo : InvalidOperation: (:) [Set-WmiInstance], ManagementException + FullyQualifiedErrorId : SetWMIManagementException,Microsoft.PowerShell.Commands.SetWmiInstance
Please someone can help me ?
That is not how we create shartes with WMI.
See the repository for examples:
Here is a good blog onhow to do this: http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/16/how-to-use-powershell-to-create-shared-folders-in-windows-7.aspx
¯\_(ツ)_/¯
- Marked As Answer by Bill_StewartMicrosoft Community Contributor, Moderator Saturday, November 24, 2012 5:16 PM

