You can use the following basic syntax to calculate the difference between two dates in PowerShell: $date_diff = New-TimeSpan -Start $date1 -End $date2 This particular…
Category: Uncategorized
You can use the following syntax in PowerShell to create an array from a CSV file: $my_csv = Import-Csv “c:\users\bobbi\basketball_data.csv” $my_array = foreach ($row in…
You can use the following basic syntax to compare two times in PowerShell: $datetime1.TimeOfDay -lt $datetime2.TimeOfDay This example assumes that $datetime1 and $datetime2 are both…
You can use the following syntax in PowerShell to compare the contents of two folders: $folder1 = Get-childitem “c:\users\bobbi\data1” $folder2 = Get-childitem “c:\users\bobbi\data2” Compare-Object $folder1…
You can use the following methods in PowerShell to compare two strings: Method 1: Compare two strings (case-insensitive) $string1 -eq $string2 This example checks if…
You can use the following basic syntax to compare two files in PowerShell: $file1 = “c:\users\bobbi\teams1.txt” $file2 = “c:\users\bobbi\teams2.txt” diff (cat $file1) (cat $file2) This…
You can use the following methods in PowerShell to compare the values in two arrays: Method 1: Find values that exist only in first array…
You can use the following methods in PowerShell to compare dates: Method 1: Compare Two Dates $date1 -lt $date2 This particular example checks if the…
You can use the StartsWith() method in PowerShell to check if a string starts with a specific value. One common way to use this method…
You can use the following syntax in PowerShell to only show rows in a file that do not contain specific strings: (Get-Content $my_file) -notmatch [String]::Join(‘|’,$dont_want)…
You can use the following syntax in PowerShell to check if a specific string exists in a list of strings: $list_of_strings -contains “this_string” This particular…
