Skript, millega saab public folderitesse õiguseid lisada - PowerShell
From ICO wiki
Jump to navigationJump to search
Skript, millega saab public folderitesse õiguseid lisada ja neid sealt ka eemaldada.
#Skript, millega saab lisada public folderitesse õiguseid
#Chris Sinihelm, AK41, 2010
#List public folderitest + kuupäev
$i = Read-Host "Kas sa tahad listi public folderitest? Jah/Ei"
if ($i -eq 'Jah'){
Get-Date > publicfolders.txt
Get-PublicFolder -Recurse | Format-List Name >> publicfolders.txt
Write-Host "List public folderitest on loodud faili publicfolders.txt"
}
$j = Read-Host "Kas sa tahad õiguseid lisada/eemaldada"
if ($j -eq 'lisada'){
$kaustanimi = read-host "Sisesta public folderi nimi kujul \peakaust\folder nimi"
#Kellele õiguseid tahetakse
$kasutajaalias = read-host "Sisesta tunnuse ALIAS, kellele õiguseid muudetakse: "
#Mis õiguseid tahetakse
$oigused = read-host "Vali õigused, mis lisatakse:
* None - FolderVisible
* Owner - CreateItems, ReadItems, CreateSubfolders, FolderOwner, Folder Contact, FolderVisible, EditOwnedItems, EditAllItems, DeleteOwnedItems, DeleteAllItems
* PublishingEditor - CreateItems, ReadItems, CreateSubfolders, FolderVisible, EditOwnedItems, EditAllItems, DeleteOwnedItems, DeleteAllItems
* Editor - CreateItems, ReadItems, FolderVisible, EditOwnedItems, EditAllItems, DeleteOwnedItems, DeleteAllItems
* PublishingAuthor - CreateItems, ReadItems, CreateSubfolders, FolderVisible, EditOwnedItems, DeleteOwnedItems
* Author - CreateItems, ReadItems, FolderVisible, EditOwnedItems, DeleteOwnedItems
* NonEditingAuthor - CreateItems, ReadItems, FolderVisible
* Reviewer - ReadItems, FolderVisible
* Contributor - CreateItems, FolderVisible"
#Õiguste lisamine
try
{
Add-PublicFolderClientPermission -Identity "$kaustanimi" -User "$kasutajaalias" -AccessRights $oigused;
#Kuvatakse kellele ja mis õigused on antud.
Write-Host "Järgnevale kasutajale: "
$kasutajaalias
Write-Host "Anti järgnevad õigused: "
$oigused
Write-Host "Sellisesse kausta:"
$kaustanimi
Write-Host "****************"
#Mis õigused antud kausta hetkel on
$w = Get-PublicFolderClientPermission "$kaustanimi"
Write-Host "Hetkel on antud kausta järgnevad õigused: "
$w
}
Catch
{
write-host "Midagi läks viltu (Error:" $_.Exception.Message ")"
write-host
}
}
elseif ($j -eq 'eemaldada'){
$kaustanimi = read-host "Sisesta public folderi nimi kujul \peakaust\folder nimi"
$kasutajaalias = read-host "Sisesta tunnuse ALIAS, kellele õiguseid muudetakse: "
$oigused = read-host "Vali õigused, mis eemaldatakse:
* None - FolderVisible
* Owner - CreateItems, ReadItems, CreateSubfolders, FolderOwner, Folder Contact, FolderVisible, EditOwnedItems, EditAllItems, DeleteOwnedItems, DeleteAllItems
* PublishingEditor - CreateItems, ReadItems, CreateSubfolders, FolderVisible, EditOwnedItems, EditAllItems, DeleteOwnedItems, DeleteAllItems
* Editor - CreateItems, ReadItems, FolderVisible, EditOwnedItems, EditAllItems, DeleteOwnedItems, DeleteAllItems
* PublishingAuthor - CreateItems, ReadItems, CreateSubfolders, FolderVisible, EditOwnedItems, DeleteOwnedItems
* Author - CreateItems, ReadItems, FolderVisible, EditOwnedItems, DeleteOwnedItems
* NonEditingAuthor - CreateItems, ReadItems, FolderVisible
* Reviewer - ReadItems, FolderVisible
* Contributor - CreateItems, FolderVisible"
try
{
Remove-PublicFolderClientPermission -Identity "$kaustanimi" -User "$kasutajaalias" -AccessRights $oigused;
#Mis õigused antud kausta hetkel on
$w = Get-PublicFolderClientPermission "$kaustanimi"
Write-Host "Hetkel on antud kausta järgnevad õigused: "
$w
}
Catch
{
write-host "Midagi läks viltu (Error:" $_.Exception.Message ")"
write-host
}
}else{
Write-Host "Midagi ei tehtud"
}