Powershell – Failed to enumerate SSL bindings, error code 234.

This is sometimes due to misconfiguration of the SSL certificate bindings in the registry, under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\Parameters\SslBindingInfo
In my case I had 0.0.0.0:443 in the directory multiple times.

Fix: GOTO HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\Parameters\SslBindingInfo and clean up multiple entries.

CODE – PowerShell list inactive computer accounts

How to list all computer accounts not active for X number of days.

List all computers that have been  Inactive in “Active Directory” for a specified Number of Days

Compatible with

Windows Server 2008 R2,
Windows Server 2008,
Windows Server 2003,
Windows 7,
Windows Vista,
Windows XP
Not Compatible with
Windows 2000

CODE – PowerShell create a new computer object

How to create a new computer object on Active Directory without any plug-ins.

If you need to change the container you can do so:
“$objDomain = New-Object System.DirectoryServices.DirectoryEntry(“LDAP://OU=ASDF,DC=asdf,DC=asdf”)”
sAMAccountName requre a string $ at the end.

Works with:
Windows Server 2008 R2
Windows Server 2008
Windows Server 2003
Windows 7
Windows Vista
Windows XP

CODE – PowerShell get domain computer accounts

Searches Active Directory for computer objects older than the date specified

CODE – PowerShell auto start services that have stopped

Start AutoStart Services that have Stopped

‘Get services that should be started (StartMode = Auto) but are stopped (State = Stopped), then start these services

CODE – PowerShell shutdown-computer

Function Shutdown Computer

Synopsis: Will shutdown, Log Off or Reboot a remote or a local computer.
Description: Will shutdown, Log Off or Reboot a remote or a local computer. Force will shutdown open programs etc.
Example: Shutdown-Computer mycomputer ‘Log Off’
Will Log Off the computer mycomputer
Shutdown-Computer mycomputer ‘Shutdown’
Will Shutdown the computer mycomputer
Shutdown-Computer mycomputer ‘Reboot’
Will Reboot the computer mycomputer
Shutdown-Computer mycomputer ‘Power Off’
Will Power Off the computer mycomputer
Shutdown-Computer mycomputer ‘Log Off’ other
Will Log Off the computer mycomputer with other credentials

CODE – PowerShell get-features information

Function Get-Features

Synopsis:Will get features on your computer
Description:Will get features on your computer.
Works on Windows 7 and Windows Server 2008 R2
Get-FeaturesWill list all installed and all avaiable features
(Get-Features).countWill show how many features you have on your computer
Get-Features installedWill list all installed features
(Get-Features installed).countWill show how many installed features you have on your computer
Get-Features availableWill list all avaiable features
(Get-Features available).countWill show how many avaiable features you have on your computer

CODE – PowerShell get user object info

Get user object information for Active Directory

This code demonstrates how to search and retrieve User Object information from Active Directory without any plug-ins.
To run this script within your environment you should only need to copy and paste this script into either Windows Powershell ISE with the following changes to the script which I have numbered below.
Change the line, ($strUserName = “samAccountName”), so that you have a real User ID.
You can also search in a specific Active Directory OU By changing the second line of code
From: “$objDomain = New-Object System.DirectoryServices.DirectoryEntry”
To: “$objDomain = New-Object System.DirectoryServices.DirectoryEntry(“LDAP://OU=ASDF,DC=asdf,DC=asdf”)”

CODE – Powershell get-ad information

Get-AD

This Script retrieves information from Active-Directory. It’s got a few Parameters and Switches that allows us to specify what to search for and how to Return the objects found. You can choose which information to return through the Property parameter, you can Save the Information to a Csv file, You can return a System.DirectoryServices.DirectoryEntry Object that you can work with through PowerShell and alot more.

Parameters:

  • -Domain Name of the Domain (Required)
  • -OU Name of Organizational Unit (Optional)
  • -User Name of the User (Optional)
  • -Group Name of the Group (Optional)
  • -Computer Name of the Computer (Optional)
  • -Filter Filter on Specified Criteria, default is name (optional)
  • -CustomFilter Create A custom SearchFilter (optional)
  • -CustomAll Create A Custom SerachFilter, searches for All Objects (optional)
  • -Property Specify one or more Properties to Return (Optional)
  • -ToCsv Saves the Output to a Csv File (Optional)
  • -ToObject Returns a System.DirectoryServices.DirectoryEntry Object (optional)
  • -IncreasePageSize Exceeds the default limit of 1000 Objects (optional)
  • -help Prints the HelpFile (Optional)

Here are a few Example Scenarios on running The Script

You want to display a HelpText about the Script

You want to Display Domain Information About Your Domain

You want to Connect to a Domain and store the Object in a Variable

You want to retrieve All OrganizationalUnits in your Domain and store their distiguishedName in a Csv file

You want to Get all Users and display their name and mail in your PowerShell Session

You want to Find a User, but you only know the Users sAMAccountName

 

You want to Create a Csv File with all Computers in your domain