If you are visiting for the first time. Have a look at my other post
https://tekcookie.com/powershell-one-liner/
Search for a file in a drive
Get-childItem C:\ -Recurse -Filter "*log*.txt"
Find all files having the word "log" in the filename.
Search data inside files and find the filenames
(Get-childItem C:\ -Recurse -Filter "*.txt").FullName | % { Get-Content $_ | where {$_ -like "*Sample data to search*"} | Select PSPath -Unique }
Above command will find all .txt files in C Drive which has "Sample data to search" text in it.
Get details from Registry
Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\USBSTOR\ | Select Start
Get registry information from remote computers
Invoke-Command -ComputerName "Server1","Server2" -ScriptBlock { Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\USBSTOR\ | Select Start }
Here the computer names can also be fetched from a text file of directly from AD.
Search registry
Get-ChildItem -path HKLM:\SYSTEM\ -Recurse -ErrorAction SilentlyContinue | where { $_.Name -like "*USBSTOR*" }
Fetch user info with logon script from AD
Get-ADUser -SearchBase "OU=TestOU,OU=MainTestOU,DC=domain,DC=local" -filter * -properties scriptpath | where { $_.scriptpath -notlike "" } | select Name, SamAccountName, scriptpath | ft * -AutoSize
To fetch Name, Sam account name & Logon script of users and filters out who do not have a Logon script.
Hope this will be helpful.
Thank you
Recent Comments