Thursday, February 16, 2017
get network share and grant full access using powershell Smb-commands
I had problem when I created network share using command Get-WmiObject Win32_Share I only had read access. So I found out that granting full access can be done by Grant-SmbShareAccess.
To get smb share:
Get-SmbShare -Name shareName
To grant user access:
Grant-SmbShareAccess -Name shareName-AccountName accountName@domain.local -AccessRight Full
Monday, January 2, 2017
Backup to network folder, display message if folder not available. [Powershell]
This example backups Thunderbird profiles to precreated network share. It can be added to task scheduler. It sends net message to current user if network share does not exist.
$name="user"
$backupDir = "\\server\backup\workstations"
$backupFolder = $backupDir + "\" + $name + "\"
$date = get-date -Format ddd
echo $backupFolder
echo $env:APPDATA/Thunderbird
cd $env:APPDATA/Thunderbird
if (-Not (Test-Path -Path $backupFolder)) {
msg.exe $env:UserName "Path[$backupFolder] not found, unable to backup"
return 0x10
}
if (-Not (Test-Path -Path $backupFolder$date)) {
New-Item -Path "$backupFolder$date" -ItemType Directory
}
else
{
echo "Path: $backupFolder$date already exists, skipping"
}
Copy-Item "Profiles/*" -Recurse -Destination $backupFolder$date -Force
Subscribe to:
Posts (Atom)