Find Free Disk Space for a drive from a list of Servers

In order to get free disk space details for C: Drive of a list of Servers, execute below PS command.

Get-WmiObject -Class Win32_LogicalDisk -ComputerName (Get-Content C:\temp\Servers.txt) -Filter “DeviceId=’C:'”|

Format-Table SystemName, @{Name=”Free”;Expression={[math]::round($($_.FreeSpace/1GB), 2)}},
@{Name=”Total Size”;Expression={[math]::round($($_.Size/1GB), 2)}} –auto
The list of Servers is stored under C:\temp\Servers.txt.
The output will give the Computername, Total Disk Space and Free Disk Space.

Adding Domain user to local group on multiple computers

Want to add a user to a local group in multiple computers ? Try below steps.
Step 1. Copy Psexec.exe on your server. You can download it from here.
Step 2: Create Servers.txt in the same location where Psexex.exe resides and store the multiple computers IP.
Step 3 : Open Command prompt with Admin Privileges and change directory to where Psexec.exe resides.
Step 4: Execute below command now
Psexec.exe @servers.txt NET.exe LocalGroup Administrators domain\username /add 
Above example is for adding the user to Administrators group. If you need to add it to another group like Remote Desktop Users, enclose it within quotes.

Psexec.exe @servers.txt NET.exe LocalGroup “Remote Desktop Users” domain\username /add

Computer Administration Tools

Application Data Folder
Home Directory Drive
Home Directory
Shared Home Directory
Temporary Folder
Windows Root Drive
Windows Root Directory

Essential Network Troubleshooting Commands

arp -a  Shows gateway MAC address.
 gpresult  Starts the Operating System Group Policy Result tool
 ipconfig /all  Displays the full TCP/IP configuration for all adapters
 ipconfig /flushdns  Flushes the DNS resolver cache. Helpful when troubleshooting DNS name resolution problems
 nbtstat -a  Obtains info from WINS or LMHOST (discovers who is logged on)
 nbtstst -A  Gets info from WINS or LMHOST (discovers who is logged on)
 nbtstat -R  Purges and reloads the remote cache name table
 nbtstat -n  Lists local NetBIOS names.
 nbtstat -r  Useful for detecting errors when browsing WINS or NetBIOS
 netstat -ab  The b switch links each used port with its application
 netstat -an  Shows open ports
 netstat -an 1 | find “15868”  Locates only lines with the number 15868 and redisplays every one second
 netstat -an | find”LISTENING”      Shows open ports with LISTENING status
 net use   Retrieves a list of network connections
 net use file://  Sees if the machine can poll IP
 net user  Shows user account for the computer
 net user /domain  Displays user accounts for the domain
 net user /domain <UserName>  Shows account details for specific user
 net group /domain  Shows group accounts for the domain
 net view  Displays domains in the network
 net view /domain  Specifies computers available in a specific domain
 net view /domain: <DomainName> | more  Shows user accounts from specific domain
 net view /cache   Shows workstation names
 nslookup  Looks up IP/hostnames and displays information helpful in diagnosing DNS issues
 ping -a  Resolves IP to Hostname
 ping -t  Pings host until stopped
 set U  Shows which user is logged on
 set L  Shows the logon server
 telnet <IP> <port>  Confirms whether the port is open

net use %LOGONSERVER%       Use this command to hit the Domain Controller resulting in DC Agent                                                              picking up the user name you logged onto the server with.

Exchange – Find All Disabled User Accounts NOT Hidden From The Address Book

Quick Powershell one-liner to find disabled accounts that are not hidden from the GAL.

Get-Mailbox -Filter{(HiddenFromAddressListsEnabled -eq $false) -AND (UserAccountControl -eq "AccountDisabled, NormalAccount")}

Powershell – Bulk User Password Resets

Simple Powershell script to bulk reset passwords from a text file containing one user per line. This makes use of the Get-ADUser, Set-ADUser, and Set-ADAccountPassword Powershell active directory cmdlets.

# import the AD module
if (-not (Get-Module ActiveDirectory)){
    Import-Module ActiveDirectory -ErrorAction Stop           
# set new default password
$password = ConvertTo-SecureString -AsPlainText "Password01" -Force 
# get list of account names (1 per line)
$list = Get-Content -Path c:\scripts\users.txt
# loop through the list
ForEach ($u in $list) {
    if ( -not (Get-ADUser -LDAPFilter "(sAMAccountName=$u)")) {
        Write-Host "Can't find $u"
    else {
        $user = Get-ADUser -Identity $u
        $user | Set-ADAccountPassword -NewPassword $password -Reset
        $user | Set-AdUser -ChangePasswordAtLogon $true
        Write-Host "changed password for $u"

Windows – Reset Local Administrator Password Remotely

he Pspasswd utlitiy, which comes as part of the Sysinternals PsTools kit, can be used to reset the local administrator password on machines locally or remotely. Obviously, this comes in handy when you’re not sure of the local administrator password on a domain joined machine.

Resetting the local administrator account on a single machine:

pspasswd \\ administrator "passwordGoesHere"

You can also specify a list of computer names in a text file to change the password on multiple machines. The example below assumes computerlist.txt contains a list of computer names, one per line:

pspasswd \\@computerlist.txt administrator "passwordGoesH

How to reset the Default Domain Group Policy Objects (DCGPOFIX)

If you have ever read my Best Practice for Group Policy blog post then you will know that I encourage you to edit the default domain GPO’s sparingly. The only exception I would make to this rule is when you want to modify the default domain password policy but even then you can create a new password policy GPO linked at the domain level (See Tutorial: How to setup Default and Fine Grain Password Policy )

Even if you don’t want to take my word for it here is a reference on the TechNet web site say pretty much the same thing…

TechNet: Establishing Group Policy Operational Guidelines

Do not modify the default domain policy or default domain controller policy unless necessary. Instead, create a new GPO at the domain level and set it to override the default settings in the default policies.

So… Lets assume you have done everything wrong and either the Default Domain and/or the Default Domain Controller Group Policy objects have been modified and you want to reset them back. Of course you have a backup of the GPO’s which are good and you simply restore them….

BUT… You have never backed up the default GPO’s and you need to reset the setting…. Well the tool that allows you to do this is called DCGPOFIX and it can be found on any Windows Server 2003 or later windows server.

NOTE: Even though we are restoring the default domain GPO’s back to a default setting doing so may still cause more issues. Therefore make sure you have a current back of your default domain so you can easily undo this change if needed (see below).



TIP: Even if you are not going to run this command I would still make of these Default Domain GPO’s now…  right now…. Go on… Its not going to hurt and this will at least give you something to roll back if you need to in the future.

The command to restore the GPO’s to default is as simple as running the “DCGPOFIX.exe” from a command line and press “Y” twice when prompted.


Now you are done. You will notice any changes to the GPO have now been removed or reverted back to the default settings. Monitor your systems for any adverse affect and make sure that you have another backup of the GPO’s for future reference.

Note: By default this command will not run if the version of the OS does not match that of the Schema version in AD.


%d bloggers like this: