Import-Module RemoteDesktop
Set-RDWorkspace -Name "My Apps"
powershell
All posts tagged powershell
$users = Get-Content c:\scripts\list.txt
ForEach($userlist in $users)
{
$user = Get-ADUser $userlist
$dn= [ADSI](“LDAP://” + $user)
$acl= $dn.psbase.objectSecurity
if ($acl.get_AreAccessRulesProtected())
{
$isProtected = $false # $false to enable inheritance
# $true to disable inheritance
$preserveInheritance = $true # $true to keep inherited access rules
# $false to remove inherited access rules.
# ignored if isProtected=$false
$acl.SetAccessRuleProtection($isProtected, $preserveInheritance)
$dn.psbase.commitchanges()
Write-Host($user.SamAccountName + "|" + `
$user.DistinguishedName + `
"|inheritance set to enabled")
}
else
{
write-host($user.SamAccountName + "|" + `
$user.DistinguishedName + `
"|inheritance was already enabled - no change")
}
}
Install-Module Microsoft.Graph -Scope AllUsers
$AllFolders = Get-ChildItem -Directory -Path "\\server\Share$\" -Force -depth 3 $Results = @() Foreach ($Folder in $AllFolders) { $Acl = Get-Acl -Path $Folder.FullName foreach ($Access in $acl.Access) { if ($Access.IdentityReference -notlike "BUILTIN\Administrators" -and $Access.IdentityReference -notlike "domain\Domain Admins" -and $Access.IdentityReference -notlike "CREATOR OWNER" -and $access.IdentityReference -notlike "NT AUTHORITY\SYSTEM") { $Properties = [ordered]@{'FolderName'=$Folder.FullName;'AD Group'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited} $Results += New-Object -TypeName PSObject -Property $Properties } } } $Results | Export-Csv -path "C:\temp\FileName - $(Get-Date -format MMyy) b.csv"
Get-VM | ForEach-Object {Get-VHD -ComputerName $_.ComputerName -VMId $_.VMId} | Select -Property path,computername,vhdtype,@{label='Size(GB)';expression={$_.filesize/1gb -as [int]}}
$DNSEntrys = import-csv “h:\dns.csv” ForEach ($dns in $DNSEntrys){ $hostname = $($dns.hostname) $ipaddress = $($dns.ipaddress) Write-host $hostname $ipaddress Add-DnsServerResourceRecordA -Name $hostname -IPv4Address $ipaddress -ZoneName contoso.com -ComputerName dc01 -CreatePtr }
Export-DhcpServer -ComputerName "oldDhcp.contoso.com" -Leases -File "C:\DHCP\OldDHCPConf.xml" –Verbose
If you have the following error:
——————————————————– Microsoft Exchange Error ——————————————————– Cannot activate database copy ‘Activate Database Copy…’. Activate Database Copy… Failed Error: An Active Manager operation failed. Error The database action failed. Error: An error occurred while trying to validate the specified database copy for possible activation. Error: Database copy ‘db1′ on server ‘dag1′ has content index catalog files in the following state: ‘Failed’.. [Database: db1, Server: dag1] An Active Manager operation failed. Error An error occurred while trying to validate the specified database copy for possible activation. Error: Database copy ‘db1′ on server ‘dag1′ has content index catalog files in the following state: ‘Failed’..First view / verify the copy status.
Get-MailboxDatabaseCopyStatus | fl name, contentindexstateUpdate the catalog
Update-MailboxDatabaseCopy "db1/dag1" -CatalogOnly
(Get-Mailbox -resultsize unlimited).count
Set-MailboxMessageConfiguration -Identity USERNAME -ReadReceiptResponse neversend