This script set the correct security rights on an organizational unit to delegate the Unlock user account permission for a specific group. In this script I will use the following informations : – Authorize the group “Helpdesk_grp” to unlock the
Reboot task optimization in a VMware Virtual Desktop Infrastructure
Create GeoIP firewall rules for iptables
Get the server uptime in days with WMI
Get GDI handles by process
This script requires Powershell 3.0 This script get the number of GDI handles by process Script : $global:sig = @’ [DllImport(“User32.dll”)] public static extern int GetGuiResources(IntPtr hProcess, int uiFlags); ‘@ Get-Process | select ProcessName -Unique | ? {$_.processname -notmatch “Idle|System|svchost”}
Resolve or get SID for Active Directory object
The following little scripts will allow you to play and take your first steps with the Active Directory object SID Resolve object SID to username $objSID = New-Object System.Security.Principal.SecurityIdentifier(“S-1-5-21-123456789-1234567890-123456789-12345”) $objUser = $objSID.Translate( [System.Security.Principal.NTAccount]) $objUser.Value Get the SID of a username
Query remote servers for installed hotfix
Set folders ACL (owner and NTFS rights)
Set DNS server ip address information on remote servers
Ping computer with a specific OS
This script use WMI to ping a list of computers. Only specific OS are pinged. Script (with Microsoft Active Directory module loaded : import-module activedirectory) : $ping = new-object System.Net.NetworkInformation.Ping $list = Get-ADComputer -LDAPFilter “(|(operatingsystem=Windows XP*)(operatingsystem=Windows 7*)(operatingsystem=Windows Vista*))” ForEach ($b