PowerTip: Use PowerShell to Get List of FSMO Role Holders


Get-ADDomain | Select-Object InfrastructureMaster, RIDMaster, PDCEmulator

Get-ADForest | Select-Object DomainNamingMaster, SchemaMaster

Get-ADDomainController -Filter * |

     Select-Object Name, Domain, Forest, OperationMasterRoles |

     Where-Object {$_.OperationMasterRoles} |

     Format-Table -AutoSize

Advertisements

All the computer Services Status


get-adcomputer -filter * | foreach { Get-WmiObject Win32_service -Computer $_.name } | select-object systemname, displayname,startname, state

Posted in Script. 2 Comments »

PowerShell ForEach Loop


$UserData = “C:\Temp\UserData.CSV”
$CSVFile = Import-CSV $UserData
Foreach ($ThisUser in $CSVFile)
{
$ModifyThisUser = $ThisUser
$NewDepartment = $ThisUser.Department
$NewCity = $ThisUser.City
Set-ADUser -Identity $ModifyThisUser -City $Newcity
Set-ADUser -Identity $ModifyThisUser -Department $NewDepartment
}

http://techgenix.com/powershell-foreach-loop/

Local account creation via batch script


@echo off

net user “gsmcwL3” “pass@123″ /add /comment:”gsmcwL3″ /fullname:”gsmcwL3”

net localgroup “Administrators” “gsmcwL3” /add

WMIC USERACCOUNT WHERE “Name=’gsmcwL3′” SET PasswordExpires=FALSE

WMIC USERACCOUNT WHERE “Name=’gsmcwL3′” SET Passwordchangeable=FALSE

event log convert into evtx to csv


Get-WinEvent -FilterHashtable @{Path=”D:\ABC-CHDGAN-DC01\Security_EVT_Log_2018_3_29_0h\Archive-Security-2018-03-28-06-36-52-244.evtx”} | Export-csv -path “D:\ABC-CHDGAN-DC01\CSV\Archive-Security-2018-03-28-06-36-52-244.csv”

AD computers report


Get-ADComputer -Filter * -Property * | Select-Object Name,OperatingSystem,DistinguishedName,modifyTimeStamp,LastReboot | Export-CSV AllWindows.csv -NoTypeInformation

Find All Active/Used IP Addresses on Your Network


Open the Command Prompt and type in the following:

FOR /L %i IN (1,1,254) DO ping -n 1 192.168.10.%i | FIND /i “Reply”>>c:\ipaddresses.txt

%d bloggers like this: