Tag: PowerShell

Verify Connectivity to a Remote Computer

Verify Connectivity to a Remote Computer

Telnet from a Windows Machine

When providing accessible public services a requirement may arise to test the connectivity externally. This can be done using the built in command line Telnet subject to the Telnet Windows feature is installed. This is unlikely as in most scenarios, Telnet is only installed if required. Additionally, using Putty you can achieve the same result, however try downloading Putty through some Proxy’s and you wont have much luck. But using the built in Windows 10 PowerShell command Test-NetConnection, this is easily achiveable. If you need to test SMTP, HTTP, HTTPS, running  the below command can provide you with either “True” or “False”.

Test-NetConnection -Port 80 -ComputerName kamhussain.com | ft TcpTestSucceeded


Uninstall a Windows HotFix

Uninstall a Windows HotFix

Removing a Windows hotfix

To uninstall a Windows hotfix, locate the KB hotfix number and run the below PowerShell command:

function Uninstall-Hotfix {
[string] $computername,
[string] $HotfixID
$hotfixes = Get-WmiObject -ComputerName $computername -Class Win32_QuickFixEngineering | select hotfixid            
if($hotfixes -match $hotfixID) {
    $hotfixID = $HotfixID.Replace("KB","")
    Write-host "Found the hotfix KB" + $HotfixID
    Write-Host "Uninstalling the hotfix"
    $UninstallString = "cmd.exe /c wusa.exe /uninstall /KB:$hotfixID /quiet /norestart"
    ([WMICLASS]"\\$computername\ROOT\CIMV2:win32_process").Create($UninstallString) | out-null            
    while (@(Get-Process wusa -computername $computername -ErrorAction SilentlyContinue).Count -ne 0) {
        Start-Sleep 3
        Write-Host "Waiting for update removal to finish ..."
write-host "Completed Uninstall of $hotfixID"
else {            
write-host "Hotfix($hotfixID) not found"
Uninstall-HotFix -ComputerName PC1 -HotfixID KB3068708
Set AD Password with PowerShell

Set AD Password with PowerShell

Set a user’s Active Directory password using PowerShell

To set a AD password via PowerShell using plain text run the below PowerShell Command:

Set-ADAccountPassword –identity karchbol -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "1234" -Force)
Get AD Group and Members Of

Get AD Group and Members Of

Find members of an Active Directory Group

In order to retrieve a group and all of its members run the following in PowerShell. You will need the AD PowerShell module which is installed with RSAT.

Get-ADGroup -Filter 'groupcategory -eq "distribution"' |
#You can filter -eq distribution or security or *

          [email protected]{GroupName=$_.Name;Member=''}

          $_ | Get-ADGroupMember -ea 0 -recurs |



                    New-Object psObject -Property $hash


          } | 

     sort groupname,member | export-csv c:\group.csv
Remove the Source Files from Windows

Remove the Source Files from Windows

Free up disk space by removing Windows source files (sxs)

Removes the payload (source files for a disk)

Unintstall-windowsferatures <> -remove

Install Windows Features:

Install-windowsfeatures  [name of feature]

Uninstall Windows Features:

Uninstall-windowsfeatures [name of feature]

Get all Windows Features: