Get File Name and Extension from Path
# Return just the file name [System.IO.Path]::GetFileName($FilePath) # Returns file name without the extension [System.IO.Path]::GetFileNameWithoutExtension($FilePath) # Returns the file extension only [System.IO.Path]::GetExtension($FilePath)
Grant Permissions to Folder Share
Grant-SmbShareAccess -name $ShareName -AccountName $Account -AccessRight Full -Force
Revoke All Permissions From Folder Share
Get-SmbShareAccess -name $ShareName | Foreach {Revoke-SmbShareAccess -name $ShareName -AccountName $_.AccountName -Force}
Create a Folder Share
$Shares=[WMICLASS]'WIN32_Share' $sd = ([WMIClass] "Win32_SecurityDescriptor").CreateInstance() $shares.create($FolderPath, $ShareName, 0, 100, "Description", "", $sd)
Create Folder If It Doesn’t Exist
If (-not(test-path $FolderPath)){ New-Item -type directory -Path $FolderPath }