THX for sharing this great utils. lp,J
How fun! I linked to this on last weekend's weekly roundup and am just now getting around to letting you know. (I guess we were busy celebrating Easter!) Thanks so much for sharing!
I imported the modules as instructed. I can see "ShareUtils" under -ListAvailable. Get-Command -Module ShareUtils does not return and results. No help listed under Get-Help. Please-Help!
It looks like you haven't imported it via Import-Module cmdlet.
Thanks for sharing shareutils. There's an issue with AllowMaximum (default $true), and MaximumAllowed (default 0). If I leave the default settings in order to allow maximum connection with the share, the script will create the share with 0 allowed connections. (Tested on Windows 7 and Windows Server 2008 R2) As a workaround I replaced each $ShareInfo.MaximumAllowed with $(if (!($ShareInfo.AllowMaximum)) {$ShareInfo.MaximumAllowed}) But, this approach is not perfect because it's not possible to toggle between allow maximum and allow a fixed number.
After extracting the zip to its own folder in %WINDIR%\System32\WindowsPowerShell\v1.0\Modules, when I launched 'Windows Powershell Modules' I got the following error: WARNING: File C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ShareUtils\ShareUtils.psm1 cannot be loaded. The contents of file C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ShareUtils\ShareUtils.psm1 may have been tampered because the hash of the file does not match the hash stored in the digital signature. The script will not execute on the system. Please see "get-help about_signing" for more details..
ditto
This can be due to invalid execution policy. Start elevated PowerShell and type: Set-ExecutionPolicy RemoteSigned
ditto
Additionally you need to unblock downloaded files (right-click on each and click Unblock in file properties).
Does not seem to work on 2008 R2 Cluster Shares. I created a share called TEST$ and it could not find it when I did a get-share. Bummer.
Is there any way to accomplish this without WMI? I'm looking for a way to remotely manage shares on a non-Windows NAS storage system. I can use Computer Management MMC to connect to the NAS remotely and manage the shares, but looking for a way to do it without WMI since it's not supported on the NAS.
I'm not aware about other ways.
Is there any way to accomplish this without WMI? I'm looking for a way to remotely manage shares on a non-Windows NAS storage system. I can use Computer Management MMC to connect to the NAS remotely and manage the shares, but looking for a way to do it without WMI since it's not supported on the NAS.
Is there any way to accomplish this without WMI? I'm looking for a way to remotely manage shares on a non-Windows NAS storage system. I can use Computer Management MMC to connect to the NAS remotely and manage the shares, but looking for a way to do it without WMI since it's not supported on the NAS.
Can you please fix the code or show the syntax required to allow maximum connections to a share.
Are you sure that new created share do not allow maximum connections?
Yes, I am sure. the default if no entry is put in is 0 so it creates a share with no user access allowed.
In ShareUtils.psm1 change line 46 from "public int MaximumAllowed;" to "public long MaximumAllowed;",and in New-Share.ps1 change line 50 from from "[int]$MaximumAllowed = 0" to "[long]$MaximumAllowed = 4294967295". This fixed it for me.
The fix for MaximumAllowed above worked great for me as well on a Server 2012. Thanks!
Im having problems running command Add-SharePermission, could please provide me an example to run this command?
Im having problems running command Add-SharePermission, could please provide me an example to run this command?
Thanks for sharing this module. Helped me out creating shares on remote servers.
Thanks for creating this module, very useful. I have a problem however, I am unable to create a share with the format "\\servername\e$\directory\directory", " sharename$" No error messages, just doesn't work. If I use a local path, it works fine. I also get the same result if I use the [WMICLASS]�WIN32_Share� method with $ Shares.Create. Any ideas? thanks for the help
Thanks for creating this module, very useful. I have a problem however, I am unable to create a share with the format "\\servername\e$\directory\directory", " sharename$" No error messages, just doesn't work. If I use a local path, it works fine. I also get the same result if I use the [WMICLASS]�WIN32_Share� method with $ Shares.Create. Any ideas? thanks for the help
Thank you for this module, it has seriously saved me many of hours of work trying to make this happen in my new user creation script!
Here's how I create my remote shares, you can try this:
$Alias =
-Path parameter expects the *local* path on remote server, not UNC (which is not supported). In your case, the -Path parameter shoud be "d:\
The get-share cmdlet doesn't show any share using "virtual computer name" get-share -name "anysharename" -computername "clusterfileservername"
The module (and underlying API) do not support virtual names. Instead, you must specify cluster node names. It is by design.
Parsing a manually created share with a group having FULL rights is listed in the SecurityDescriptor property as Read. Other than that so far appears to be good.
I see the ModuleType as Script and the only exported command available is Test-ElevatedShell. Im running Win7 client talking to a Win2008r2 server. Is it my environment?
what "Get-Command -Module shareutils" returns?
I had to modify 'Get-Share' in order to get the correct value set on the Permission parameter by adding:
$Masks = @{2032127 = "FullControl"; 1245631 = "Change"; 1179817 = "Read"}
And then inserting the Permission line in where the Descriptor is being set:
$SD.Descriptor.DACL | %{
Write-Verbose "Create SecurityDescriptor object for current ACE"
$Descriptor = New-Object ShareUtils.SecurityDescriptor.SD
$Descriptor.User = $_.trustee.Name
$Descriptor.SIDString = $_.trustee.SIDString
$Descriptor.Domain = $_.trustee.Domain
$Descriptor.AccessMask = $_.AccessMask
$Descriptor.AceFlags = $_.AceFlags
$Descriptor.AceType = $_.AceType
$Descriptor.Permission = $Masks[$Descriptor.AccessMask]
$ShareInfo.SecurityDescriptor += $Descriptor
}
Another fix when adding a permission to a share which has no currently existing shares:
Modify Add-SharePermission:
Write-Verbose "Add new ACE to the existing ACL"
if ($OldSD) {
Write-Verbose "Merging new ACE with existing ACLs"
$ShareInfo.SecurityDescriptor = @(New-SD $user $AccessType $Permission) + $OldSD
}
else {
Write-Verbose "Adding new ACE with existing ACLs (empty)"
$ShareInfo.SecurityDescriptor = @(New-SD $user $AccessType $Permission)
}
Thanks for sharing, really great !
"Get-Share U *" (as shown in the examples) does not work with me unfortunately.
PS C: \ WINDOWS \ system32> Get-Share
Name ComputerName Description
---- ------------ -----------
Images ILLUMINATI
FTP Share ILLUMINATI
Kodi ILLUMINATI
Pictures ILLUMINATI
Print $ ILLUMINATI printer driver
Users ILLUMINATI
PS C: \ WINDOWS \ system32> Get-Share U *
PS C: \ WINDOWS \ system32>
__
Thanks for sharing!
Supplement:
With two letters it works however:
PS C: \ WINDOWS \ system32> Get-Share Us *
Name ComputerName Description
---- ------------ -----------
Users ILLUMINATI
Bitnugger you find bug
in file Get-Share.ps1:
replace if ($share1 -ne $null -and $share1.Type -eq 0) TO if ($share1 -ne $null)
# if ($share1 -ne $null -and $share1.Type -eq 0) {
if ($share1 -ne $null) {
There is another bug where apostrophes in the share name are not escaped on the WMI queries within the script. This caused me problems in getting shares. the fix is to modify every "gwmi" line in every script that has the share name in the filter. Append .Replace("'","\'") to the share name and it will escape apostrophes correctly.
For example: Get-Share.ps1 line 49:
$share1 = gwmi Win32_Share -ComputerName $Computer -Filter "name LIKE '$($sharename.Replace("*","%").Replace("'","\'"))'"
Download link is not working..Can you please enable it.
download link is fixed.
I'm not able to get this module to import. I believe it may be because the cert expired in 2015? I'm getting the following from an elevated PowerShell session:
Import-Module : The following error occurred while loading the extended type data file: ,
C:\Users\santkowiak\Documents\WindowsPowerShell\Modules\ShareUtils\ShareUtils.Types.ps1xml: The file was skipped
because of the following validation exception: File
C:\Users\santkowiak\Documents\WindowsPowerShell\Modules\ShareUtils\ShareUtils.Types.ps1xml cannot be loaded. A
certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider..
At line:1 char:1
+ Import-Module ShareUtils
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Import-Module], RuntimeException
+ FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
The package is signed by an untrusted certificate. You need to unblock ZIP archive and configure PowerShell execution policy to RemoteSigned.
Post your comment:
Comments: