Browsed by
Tag: Scripting

PowerShell: Get the hostname, mac, and IP remotely

PowerShell: Get the hostname, mac, and IP remotely

Normally I look around and find scripts to do things I need right away, sadly today, that was not the case! So, I looked at a few websites and was able to come up with this: $machines = Get-Content feedme.txt foreach($machinename in $machines) { get-wmiobject win32_networkadapterconfiguration -computer $machinename -filter “IPEnabled=’True'” | Select DNSHostname,MACAddress,IPAddress } Basically how it works is, you put your script and feedme.txt file in the same folder, the feedme.txt file has all of the machine names, then…

Read More Read More

PowerShell: Changing Account Expiration Dates

PowerShell: Changing Account Expiration Dates

Sometimes we need to change a large number of expiration dates and doing it by hand can be quite a task, here I have two examples on how to do this. Both required Quest Active Roles Management Shell for Active Directory. Example 1 – If all the account have an attribute such as the description that is the same, it can be done this way, but it MUST be the same and match exactly: Get-QADUser -ou “ou=users,dc=site,dc=local” -includedproperties description,AccountExpires,SamAccountName -sAMAccountName…

Read More Read More

PowerShell: Find User Accounts Expiring in 7 days

PowerShell: Find User Accounts Expiring in 7 days

This may help some of you; it looks for accounts within a certain OU and outputs their expiration date and email if their account expires in 7 days (no more, no less!). # Inspired by: http://gallery.technet.microsoft.com/scriptcenter/Email-Active-Directory-452a5640 # Modified for use by; Salomon Johns # Find users within a certain OU that have accounts expiring in 7 days (no more, no less) # Print out the results Get-QADUser -ou “ou=users,dc=test,dc=domain,dc=local” -includedproperties AccountExpires -sAMAccountName ‘*’ | ForEach-Object { $sevendays = (Get-Date).AddDays(7).ToString(‘yyyyMMdd’) $samaccountname…

Read More Read More