Skip to main content

Posts

Showing posts with the label Scripting

AD-Powershell for Active Directory Administrators

http://social.technet.microsoft.com/wiki/contents/articles/5819.ad-powershell-for-active-directory-administrators.aspx Computer object commands List all computer accounts in a domain Get-ADComputer –Filter {Name –Like "*"} View all computers that are logged in for 90 days to the Active Directory Search-ADaccount -AccountInactive -Timespan 90 -ComputersOnly OR $lastLogon = (get-date).adddays(-90).ToFileTime() Get-ADComputer -filter {lastLogonTimestamp -gt $lastLogon}  Find and delete all disabled Computer accounts in Active Directory Search-ADAccount -AccountDisabled -ComputersOnly | Sort-Object | Remove-ADComputer Find and delete disabled computer accounts from a specific OU Search-ADAccount -AccountDisabled -Searchbase "OU=IT,DC=Contoso,DC=Com" -ComputersOnly | Sort-Object | Remove-ADComputer Find and delete all computer accounts that no longer have signed up since 11/20/2011 to the Active Directory Search-ADAccount -AccountInactive -DateTime "20.11.2011...

Embedding IAM roles in EC2 instances

http://searchaws.techtarget.com/tip/Embedding-IAM-roles-in-EC2-instances Many enterprises know that turning off unused AWS instances can save money. But not all IT pros know which method is best and how to set it up. There are a few ways to turn off unused Amazon Web Services (AWS) Elastic Compute Cloud (EC2) instances. If you don't use Auto Scaling, you will need to configure this process manually. One method is to use command-line interface (CLI) tools ec2-start-instances and ec2-stop-instances on Linux, using either a role-based method or an identity access management user-credential method. Setting up role-based security enables you to associate AWS identity and access management (IAM) roles with the instance, without having to manually add plain-text security credentials. This not only improves security, but is easier to manage. Identify an instance that will perform CLI start and stop scripts, or create a dedicated micro-instance to perform these maintenance tasks. IA...

script to delete files older than x days in windows

Batch File: @echo off :: set folder path set dump_path=Path.... :: set min age of files and folders to delete set max_days=15 :: remove files from %dump_path% forfiles -p %dump_path% -m *.* -d -%max_days% -c "cmd  /c del /q @path" :: remove sub directories from %dump_path% forfiles -p %dump_path% -d -%max_days% -c "cmd /c IF @isdir == TRUE rd /S /Q @path"