To list all users in a OU, we can get it using Get-ADUser cmdlet. See the example below. (replace OU path in LDAP format to your own stuff and "Import-Module ActiveDirectory" before you run it). Get-ADUser -Filter * -SearchBase "cn=Users,dc=company,,dc=com" -properties title, department| Select-Object name,title,department Now what if you want everything (Users, Groups, Contacts, etc.,) … Continue reading PowerShell: List everything on a OU in a one line
Category: Scripting
PowerShell: How to return multiple values from a Function?
If you like to return multiple values from a function, simply populate a hash table variable in function and return the variable. See my example below. Feel free to use my example function and Enjoy. Function Get-UserInfo($username) { #Create an hashtable variable [hashtable]$Return = @{} Import-Module ActiveDirectory $ADUser = … Continue reading PowerShell: How to return multiple values from a Function?
PowerShell: Search User Accounts in Active Directory
Active Directory Module has many cmdlets to process many AD related tasks. BUT we don’t have simple search cmdlet. I had a requirement to check a list of users in AD to see if they exist or not. Get-ADUser doesn’t cut it for my requirement. If a user doesn’t exist, Get-ADUser errors out. So I … Continue reading PowerShell: Search User Accounts in Active Directory
Active Directory: Bulk User Password Reset by PowerShell
If you need to reset password for bulk number of user accounts, the following PowerShell scripts is for you. This first script requires an file with usernames listed one per line. Check the UserList.txt file location in this file. Change your favorite password in ConvertTo-SecureString cmdlet in this script. Then you are good go. ## … Continue reading Active Directory: Bulk User Password Reset by PowerShell
LastLogonTimeStamp: How to parse the 18 digit number in PowerShell?
This command generates the following results: PS H:\> Get-ADUser JohnD -Properties LastLogonTimeStamp | select Name,LastLogonTimeStamp | fl Name : John DoeLastLogonTimeStamp : 130364862459391289 If you are wondering how to parse the 18 digit number of LastLogonTimeStamp property value. This LastLogonTimeStamp is expressed using Windows File Time. A Windows file time is a 64-bit value that … Continue reading LastLogonTimeStamp: How to parse the 18 digit number in PowerShell?
PowerShell 4.0: “Get-ADUser : One or more properties are invalid”
This applies to Get-ADComputer cmdlet too. When I try to get all properties of an AD account like Get-ADUser JohnDoe –Properties * it gives following error. Get-ADUser : One or more properties are invalid. Parameter name: msDS-AssignedAuthNPolicy It used to work in older PowerShell versions (Windows 8 or Windows 7). Now my scripts are all … Continue reading PowerShell 4.0: “Get-ADUser : One or more properties are invalid”
Citrix/RDS: Publish Internet Explorer without Address Bar
Publishing IE for a web application without address bar is easier than you think. Simply publish the following VBScript or PowerShell script to launch IE without address bar and go to specific intranet website. Copy either one of the script into Notepad and save as LaunchIE.vbs for vbscript OR LaunchIE.PS1 for PowerShell. Change the website … Continue reading Citrix/RDS: Publish Internet Explorer without Address Bar
Windows Script: “WScript.CreateObject: Could not locate automation class named “WScript.Network”
When I run my VBScript Windows Script ActiveX libraries are not loading. I was getting "WScript.CreateObject: Could not locate automation class named "WScript.Network". Solution: for 32bit OS: Open command prompt Type regsvr32 c:\windows\system32\wshom.ocx Type regsvr32 c:\windows\system32\scrrun.dll for 64bit OS: Open command prompt Type regsvr32 c:\windows\SysWOW64\wshom.ocx Type regsvr32 c:\windows\SysWow64\scrrun.dll That's all. Your script should now work.
PowerShell: List Active Computers from Active Directory
I had a requirement to get list of active computers from Active Directory with some stored properties in computer account like OS, OS version and OU name where the computer account exists. I have defined the active computer as if LastLogonDate is less than 60 days. Here is the script. P.S. Your computer should be … Continue reading PowerShell: List Active Computers from Active Directory
PowerShell Grid view is “sooo” much better than Exchange 2010 Tracking Log viewer in browser
Exchange 2010 tracking log viewer is great, but you can copy/export the results or even sort the results for different needs. So far Exchange admins are run the get-messegetrackinglog in power shell and export to CSV file using export-csv cmdlet. It’s great, but greater idea is grid view. I found Power shell grid view is … Continue reading PowerShell Grid view is “sooo” much better than Exchange 2010 Tracking Log viewer in browser