Invoke-Command -ComputerName  -ScriptBlock { stop-process  }

(get-wmiobject -namespace "root\cimv2" -Class Win32_Process -Filter "name = 'wscript.exe'" -Impersonation 3 -ComputerName mycomputer).Terminate()
get-childitem -recurse | select-string -pattern "DSN" | select-object -Property Path,LineNumber,Line

get-childitem -recurse | select-string -pattern "CreateJob.*BGE-DO.*AO_SVC" | 
select-object -Property Path,LineNumber,Line #search for jog4 files Get-Childitem -Path C:\ -Include *log4j*.jar* -Recurse -ErrorAction SilentlyContinue |
foreach {$lookupresult = (zip -sf $_ | select-string -pattern JndiLookup); if($lookupresult) {write-host -foreground red $($_.Fullname) $lookupresult} else {write-host -foreground green $($_.Fullname) $lookupresult }} gci -Path C:\ -Include *log4j*.jar* -Recurse -ErrorAction SilentlyContinue | foreach {$lr = (zip -sf $_ | sls -pattern JndiLookup); if($lr) {write-host -foreground red $($_.Fullname) $lr} else {write-host -foreground green $($_.Fullname) $lr }}
add-localGroupmember -Group "Administrators" -Member "email@domain.com"
get-childitem "C:\windows\System32" -recurse | where {$_.extension -eq ".txt"} | % { Write-Host $_.FullName }
get-childitem -path \\$srvn\d$\cgi\log -recurse | where-object{$_.LastWriteTime -ge (Get-Date).date} | 
foreach-object {copy-item \\$srvn\d$\cgi\log\$_ c:\tmp\LOGSTODAY\$($_.Basename).$srvn.log}
Get-Content (Get-PSReadlineOption).HistorySavePath
$array = "server1", "server2", "server3", "server4"; foreach ($ar in $array) { gci \\$ar\d$\soft\Log\ | 
? {$_.lastwritetime -gt ‘6/3/22’ -and $_.lastwritetime.hour -ge 11} | select-string -pattern ".+?Task.+?"; echo --------------- }
#copied from https://gist.github.com/mklement0/006c2352ddae7bb05693be028240f5b6
#Add-Type -TypeDefinition @"
# using System;
# using System.Diagnostics;
# using System.Runtime.InteropServices;
#
# public static class Imagehlp
# {
#     [DllImport("imagehlp.dll", CharSet=CharSet.Auto)]
#         public static extern bool MapFileAndCheckSumA(
#             [MarshalAs(UnmanagedType.LPStr)] string Filename,
#             out int HeaderSum,
#             out int CheckSum);
# }
#"@

Add-Type -Namespace net.same2u.WinApiHelper -Name IniFile -MemberDefinition @"
  [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
  public static extern uint GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, [Out] byte[] lpBuffer, uint nSize, string lpFileName);
  [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
  public static extern bool WritePrivateProfileString(string lpAppName, string lpKeyName, string lpString, string lpFileName);
"@

Function Get-IniValue {

[CmdletBinding()] 
param(
    [Parameter(Mandatory)] [string] $LiteralPath,
                           [string] $Section,
                           [string] $Key,
                           [string] $DefaultValue
)
  # Make sure that bona fide `null` is passed for omitted parameters, as only true `null`
  # values are recognized as requests to enumerate section names / key names in a section.
  $enumerate = $false
  if (-not $PSBoundParameters.ContainsKey('Section')) { $Section = [NullString]::Value; $enumerate = $true }
  if (-not $PSBoundParameters.ContainsKey('Key'))   { $Key = [NullString]::Value; $enumerate = $true }

  # Convert the path to an *absolute* one, since .NET's and the WinAPI's 
  # current dir. is usually differs from PowerShell's.
  $fullPath = Convert-Path -ErrorAction Stop -LiteralPath $LiteralPath
  $bufferCharCount = 0
  $bufferChunkSize = 1024 # start with reasonably large default value.

  do {
    $bufferCharCount += $bufferChunkSize
    # Note: We MUST use raw byte buffers, because [System.Text.StringBuilder] doesn't support
    #       returning values with embedded NULs - see https://stackoverflow.com/a/15274893/45375
    $buffer = New-Object byte[] ($bufferCharCount * 2)
    # Note: The return value is the number of bytes copied excluding the trailing NUL / double NUL
    #       It is only ever 0 if the buffer char. count is pointlessly small (1 with single NUL, 2 with double NUL)
    $copiedCharCount = [net.same2u.WinApiHelper.IniFile]::GetPrivateProfileString($Section, $Key, $DefaultValue, $buffer, $bufferCharCount, $fullPath)
  } while ($copiedCharCount -ne 0 -and $copiedCharCount -eq $bufferCharCount - (1, 2)[$enumerate]) # Check to see if the full value was retrieved or whether the buffer was too small.
  
  # Convert the byte buffer contents back to a string.
  if ($copiedCharCount -eq 0) {
    # Nothing was copied (non-existent section or entry or empty value) - return the empty string.
    ''
  } else {
    # If entries are being enumerated (if -Section or -Key were omitted),
    # the resulting string must be split by embedded NUL chars. to return the enumerated values as an *array*
    # If a specific value is being retrieved, this splitting is an effective no-op.
    [Text.Encoding]::Unicode.GetString($buffer, 0, ($copiedCharCount - (0, 1)[$enumerate]) * 2) -split "`0"
  }
}

Get-IniValue TAL.ini REALTICK ToolBar 


---------------------------------------------------
TAL.ini
[YPERMCACHE]
URLList=https://qayperms2.realtick.com
LoginWindowPosX=200
LoginWindowPosY=100
BrandingID=4
UseAuthLocale=1
[REALTICK]
ShutdownStatus=0
YPermsFile=data\yperms.xml
YPERMS_EXCHANGE_FILE=parm\exchange.lst
ApplicationLook=7
ChartTrendType=2
PREVPAGE=daily_stocks_forex_and_futures
Position=0 0 1920 1040
Maximized=N
ToolBar=N
StatusBar=N
AutoPageNavigator=N
PageNavigatorWidth=0
UpTickRgb=32768
DownTickRgb=-842150450
StatusMonitorPos=327,137,826,386
RTConnectURL=http://www.RealTick.com/RealTicksplash/default.aspx?username=$USER&domain=$DOMAIN
AUTOPREVPAGE=N
PurgeDelay=0
AUTOFIRSTPAGE=Y
AutoPageManager=N
ShowTabBar=N
THINFRAMES=N
NOCAPTIONS=N
HoverWindowControl=N

function DisplayMenu {
Clear-Host
Write-Host @"
+===============================================+
|  POWERSHELL CONSOLE - USER MENU               | 
+===============================================+
|                                               |
|    1) PING                                    |
|    2) DISPLAY MESSAGE                         |
|    3) READ FILE                               |
|    4) EXIT                                    |
|                                               |
+===============================================+

"@

$MENU = Read-Host "OPTION"
Switch ($MENU)
{
1 {
#OPTION1 - PING
$OPTION1 = Read-Host "HOST"
Test-Connection -ComputerName $OPTION1
Start-Sleep -Seconds 2
DisplayMenu
}
2 {
#OPTION2 - DISPLAY MESSAGE
$OPTION2 = Read-Host "MESSAGE"
Write-Host "MESSAGE: $OPTION2"
Start-Sleep -Seconds 2
DisplayMenu
}
3 {
#OPTION3 - propmt to read file
$OPTION3 = Read-Host "FILE"
gc $OPTION3  -ErrorAction SilentlyContinue -ErrorVariable NotFound
if($NotFound){
	write-warning -Message 'not found'
}
Start-Sleep -Seconds 3
DisplayMenu
}
4 {
#OPTION3 - EXIT
Write-Host "Bye"
Break
}

default {
#DEFAULT OPTION
Write-Host "Option not available"
Start-Sleep -Seconds 2
DisplayMenu
}
}
}
DisplayMenu
for($y=1;$y -lt 3346;$y++){for($x=$y;$x -lt 13380;$x=$x+3345) {gc allfieldcrews.txt | select -first $x | select -last 1 >> outfile.txt}}
$jsonz = gc .\elrgapt-005_40_gzl.txt | ConvertFrom-Json


foreach( $jz in ($jsonz | Select-Object | where-object { $_.Transaction.MeasurementName -eq "PFIELD_C060_GET_AGENCY" })) {  write-Host $(($jz.Transaction.StartTime),($jz.Transaction.EndTime)) }
 $list_of_files = select-xml .\ScriptUploadMetadata.xml -Xpath '/VugenScriptMetadata//FileEntry[@Filter="4" or @Filter="2"]' | ForEach-Object { $_.node.Name }
PS C:\users\c977004> [System.Collections.ArrayList]$leaders = @(foreach ($d in  ".\export_crews_phi.csv", ".\export_crews_bge.csv", ".\export_crews_comed.csv", ".\export_crews_peco.csv") { gc $d | select -first 1500 | select -last 750 })

while ($leaders.Count -gt 0) { $el = $leaders | get-random; $el | out-file execution_file.txt -Append; $leaders.remove($el) }
Example of example.csv file Structure
-----------------------
"Date","Amount"
"08/11/2023","$84.00"
"08/10/2023","$210.08"
-----------------------


$csv = Import-Csv "example.csv"
$sm = 0
foreach($item in $csv) { $sm = $sm + [int]$($item.Amount).replace("$", "") }

$sm
294.08
("rah" | ConvertTo-SecureString -AsPlainText -Force) | ConvertFrom-SecureString
gwmi win32_logicaldisk | 
Format-Table DeviceId, MediaType, @{n="Size";e={[math]::Round($_.Size/1GB,2)}},@{n="FreeSpace";
e={[math]::Round($_.FreeSpace/1GB,2)}}
GoBack