How to automate a file search

Add-Content ‘\\BackupDC\C$\Users\mishky\Desktop\Backup.ps1’ -Value ‘Write-Host “Hello World!”’
(Get-ADComputer -Filter * -SearchBase “ou=Clients,dc=test,dc=local” -Properties *).CN | Out-File List.txt ; Rename-Item List.txt List.csv
$systems = Get-Content .\List.csv
ForEach($system in $systems)
{
Invoke-Command -ScriptBlock {Get-ChildItem -Path C:\Users\* -Filter Backup.ps1 -Recurse -ErrorAction SilentlyContinue} -ComputerName $system | Out-File .\Output.txt -Append
}
$File = Read-Host “What is the filename you are checking for?”
$List = Read-Host “What is your list of computers to check?”
$systems = Get-Content .\$List
ForEach($system in $systems)
{
Get-ChildItem -Path \\$system\C$\Users\* -Filter $File -Recurse -ErrorAction SilentlyContinue | Out-File .\OutputII.txt -Append
}

--

--

--

I work various IT jobs & like Windows domain security as a hobby. Most of what’s here is my notes from work or the lab.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Re-introduction Guide to Ansible for experienced Ansible users.

Game dev Course: First project

Using Cloudflare as DNS for a Deployed Heroku App

Use of HMS Kit in Cookpad Application

Hudson is Retiring. The end of a Jenkins’ Story.

What does droppable tombstones mean in sstablemetadata for cassandra?

Controlling the gate remotely

Unity Physics

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rich

Rich

I work various IT jobs & like Windows domain security as a hobby. Most of what’s here is my notes from work or the lab.

More from Medium

PowerShell: The Basics

image.png

Two Most Important Browser Extensions

Simple Hello World with schtasks in Windows

VSCode create Big Data Maven/Java Project on WSL2 Ubuntu on Windows