Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Output results in for loop to txt file

$
0
0

I'm trying to get this script to output the results to a txt file, but I still have a lot to learn about Powershell. This includes how to output the results of a for loop to a txt file. Any help would be appreciated. Is this the right command? Out-File -filepath C:\Test1\process.txt. If so, I'm just not sure where to put it at.

$strCategory = "computer"
$strOperatingSystem = "Windows*Server*"

$objDomain = New-Object System.DirectoryServices.DirectoryEntry("LDAP://DC=Domain,DC=com")

$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain

$objSearcher.Filter = ("OperatingSystem=$strOperatingSystem")

$colProplist = "name"
foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}

$colResults = $objSearcher.FindAll()

foreach ($objResult in $colResults)
{
$objComputer =...


Viewing all articles
Browse latest Browse all 15370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>