Cogger

ManualRun_.ps1

May 24th, 2022 (edited)
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ComputerName = $env:COMPUTERNAME
  2. $LoggedOnUser = (qwinsta /SERVER:$ComputerName) -replace '\s{2,22}', ',' | ConvertFrom-Csv | Where-Object {$_ -like "*Acti*"} | Select-Object -ExpandProperty USERNAME
  3. if (!($LoggedOnUser) ) { Write-Host "No user is logged on to $ComputerName" -ForegroundColor Red ; break }
  4. $LoggedPath = "C:\Users\$LoggedOnUser\Documents"
  5. $OnePath = (Get-ChildItem $LoggedPath -recurse | Where-Object {$_.PSIsContainer -eq $true -and $_.Name -match "OneDrive"}).Name
  6. $1DPath = $LoggedPath + "\" + $OnePath
  7. get-childitem "$1DPath" -Force -File -Recurse #| where Attributes -eq 'Hidden, Archive'
  8.  
Add Comment
Please, Sign In to add comment