
Git Command Cheat Sheet for Beginners
Git Command Cheat Sheet for Beginners Are you new to Git and feeling overwhelmed by the numerous commands? Look no further! This cheat sheet covers […]
Git Command Cheat Sheet for Beginners Are you new to Git and feeling overwhelmed by the numerous commands? Look no further! This cheat sheet covers […]
Introduction As a PowerShell administrator, securely handling credentials is one of the most critical aspects of scripting and automation. In this post, we’ll explore various […]
Introduction: Managing permissions on shared folders is a crucial aspect of maintaining data security and accessibility within an organization’s network infrastructure. Windows servers offer various […]
(Get-aduser -filter * -server Domainname:3268 | Group-Object -Property UserprincipalName | ?{$PSItem.Count -gt 1 -and $PSItem.Name -ne “”}).group |export-csv c:\temp\duplic.csv -NoTypeInformation
$AllUSers = get-aduser -filter {SamAccountName -like “z*” -and Enabled -eq $true } -Properties Memberof,EmployeeNumber -Server <Domain name> | ?{$PSItem.DistinguishedName -notmatch “OU=Service Accounts”} $results = new-object […]
$ForestInfo=Get-ADForest $Domains =$forestInfo.domains $FileName =$ForestInfo.RootDomain+”-Windows_Servers_60-9_Days_Active-“+”$(get-date -Format MM-dd-yyyy)”+”.csv” $FilePath = “c:\temp” $Daysactive = 60 $lastactive=(get-date).AddDays(-($Daysactive)) foreach($domain in $domains){ Write-Output “Working on $domain” Get-ADComputer -Filter {OperatingSystem -like […]
We can use PowerShell to test remote port connectivity without installing telnet and with the use of the Test-NetConnection command. To check if the remote […]
#Share Folder Path $FolderPath = dir -Path “\\server1.vmwarenterprise.com\Reports\” -Recurse -Directory -Force$Report = @()Foreach ($Folder in $FolderPath) {$Acl = Get-Acl -Path $Folder.FullNameforeach ($Access in $acl.Access){$Properties = […]
foreach($d in (get-adforest).domains){$v = Measure-Command {get-addomaincontroller -Filter * -Server $d}Write-Output “Took $($v.TotalSeconds) to Enumerate DCS in $d “}
Created domain account in each domain add it to domain admin group $domains = (get-adforest).domainsforeach($domain in $domains){$accountname = ‘s-coe-‘+($domain -split “.”)[0]+’-DA’$accountpass = ‘P@ssword123456’ | ConvertTo-SecureString […]
Some Enterprise Organisations do not allow us to use any software on their networks a. Any software to be installed would need to be tested, […]
#get all AD users in forest with name like v- and status is enable $allusers = (get-adforest).domains| %{get-aduser -filter {SamAccountName -like “v-*” -and Enabled -eq […]
#Domain names in forest $ForestInfo = Get-ADForest$Domains =$forestInfo.domains$FileName = “DNSForwarder”+”$(get-date -Format MM-dd-yyyy)”+”.csv”$FilePath = “c:\temp”foreach($domain in $domains){Write-Output “Working on $domain”get-dnsserverforwarder -computer $domain| select IPAddress, @{l=”Domain”;e={$domain}}| Export-Csv […]
#Input file is CSV file with headers IPaddress $Computers = import-csv “c:\temp\servers.csv” ForEach ($Computer in $Computers) {Write-Host “$($Computer.IPAddress): ” -ForegroundColor YellowInvoke-Command -ComputerName $Computer.IPAddress -ScriptBlock { […]
#Created domain user and add user account to domain group $domains = (get-adforest).domainsforeach($domain in $domains){$accountname = ‘s-user-‘+($domain -split “.”)[0]+’-DA’$accountpass = ‘P@ssword123456’ | ConvertTo-SecureString -Force -AsPlainTextWrite-Output […]
$Computers = GC “c:\temp\servers.txt” foreach($computer in $computers){Get-WMIObject Win32_NetworkAdapterConfiguration -Computername $Computer | Where-Object {$_.IPEnabled -match “True”} |Select-Object -property DNSHostName,@{N=”DNSServerSearchOrder”;E={“$($_.DNSServerSearchOrder)”}},@{N=’IPAddress’;E={$_.IPAddress}}|export-csv c:\temp\DNSlist.csv -NoTypeInformation -append#@{N=’DefaultIPGateway’;E={$_.DefaultIPGateway}}}
Connect to Vcenter Connect-VIServer vmwareenterprise.com -WarningAction 0 ####### Shutdown all VMs from the list “C:\temp\vm.txt“########### foreach($vmlist in (Get-Content -Path C:\TEMP\vm.txt)) { $vm = Get-VM -Name […]
dsquery user -startnode forestroot -samid <username> | dsmod user -pwd <new_password> DsQuery | HomeWorks’s Blog (wordpress.com)
Add multiple DNS servers as name servers to multiple DNS zones all in once. So this is essentially adding NS resource records to a zone, […]
$invalidChars = ‘:\\/’ + [RegEx]::Escape(-join [IO.Path]::InvalidPathChars) $backupDir = ‘C:\temp\backup’ Get-GPO -All -Domain <DOmain Name>| ForEach-Object { $name = $_.DisplayName -replace “[$invalidChars]”, ‘_’ $gpoDir = Join-Path […]
Function Name: Get-LoggedIn # ——————————————- # Function Name: Get-LoggedIn # Return the current logged-in user of a remote machine. # ——————————————- function Get-LoggedIn { […]
Function Name: Get-Uptime # ——————————————- # Function Name: Get-Uptime # Calculate and display system uptime on a local machine or remote machine. # ——————————————- function […]
Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Scope User -Confirm:$false Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Scope User -Confirm:$false #$cred = Get-Credential Domain\username Connect-VIServer VCenter-Name -Credential $cred -force & { foreach ($vCenterServer […]
Note: This script will overwrite the existing Notes, so use it at your own risk! My colleague asked me to add some notes to the […]
cls Function New-RemoteProcess { #[CmdletBinding()] Param( [String]$ComputerName = $env.computername, [String]$Cmd = $(Throw “You must enter path to the command which will create the process”), [String]$ac, […]
Get-Content C:\temp\Computers.txt| %{Move-ADObject -Identity “CN=$_,OU=WIN10,OU=ABC,OU=Computers,DC=CHILD,DC=Domain,DC=Vmwareenterprise,DC=com” -TargetPath “OU=Prod,OU=WIN10,OU=ABC,OU=Computers,DC=dev,DC=DIR,DC=vmwareenterprise,DC=com”} -Verbose
Description The Get-ADOrganizationalUnit cmdlet gets an organizational unit (OU) object or performs a search to get multiple OUs. This cmdlet gets a default set of OU object […]
Just give input as first name and last name in inputfile Jeevan bobba Abcdef ghijklmnopqrst It will create username and by adding v- at […]
Computer uptime is an important statistic in systems management. Here are several of the ways we can determine system uptime for a computer (note that […]
Delete Files from Remote computers The following PowerShell script recipe will help you delete a remote file based on a list of computers stored in a text file. New PowerShell function […]
Connecting to individual host Open VMware vSphere PowerCLI console #Connect to the host Connect-VIServer -Server hostname.example.com #Get all VMs from the host, filter those powered […]
Towards a better console – PSReadLine for PowerShell command line editing Sometimes text mode is where it’s at. I’ve long blogged about tools and […]
Powershell script to email ###########Define Variables######## $date = “get-date” $fromaddress = “[email protected]” $toaddress = “[email protected]” $Subject = “Test $(get-date)” $body = Get-Content C:\temp\Test.htm #$attachment = […]
I often have to copy files and folders from one server to another for various reasons. Copying stuff manually is a bore but if you […]
Function New-RemoteProcess { #[CmdletBinding()] Param( [String]$ComputerName = $env.computername, [String]$Cmd = $(Throw “You must enter path to the command which will create the process”), [String]$ac, [String]$wait […]
I tried to make this script as simple as possible for day-to-day use. This script takes three parameters: ObjectType: Type of object that you want […]
PowerCLI 6.5.1 has been released and in this release VMware have made some big changes to the way you install and keep up to date […]
If the function name contains a hyphen (eg. test-computername): ${function:test-Computername} Alternatively: (Get-Command test-Computername).Definition Or cat function:show-list To export function to text file cat function:test-computername >c:\temp\function
POWERSHELL SCRIPT COPY fILES USING ROBOCOPYPOWERSHELL SCRIPT COPY fILES USING ROBOCOPY Please find powershell code which will assist you in copying data from source location to destination […]
Copyright © 2025 | WordPress Theme by MH Themes