Link to home
Start Free TrialLog in
Avatar of compdigit44
compdigit44

asked on

PowerShell Send all resullts to one file

I am trying to write a simple Powershell script which I can run to query the environment and look for the presence of a directory

Here is what I am looking for as as example:

  $env:COMPUTERNAME ; Test-Path c:\users ;get-date

I would like all results display on the powershell console and append to a file the with each workstation result listed on one line each
Avatar of oBdA
oBdA

Something like that, or what is it exactly you're planning to do?
"$($ENV:ComputerName);$(Test-Path C:\Users);$(Get-Date)" >>"\\SomeServer\SomeShare\SomeFile.txt"

Open in new window

Avatar of compdigit44

ASKER

Thank!!!

 Now if I wanted to run this against a list of device but have it report the results to the console and file how would I do that. I would assume I would need WinRM enabled for this.

I am asking since I an inventorying a companies small network which we just took over
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks so much...

I understand the get-content is for the text file list all devices but I am confused as to the first two lines
$Share is the share under which the path is when accessed remotely; for C:\Users, that would be the administrative share C$.
$Path is the path to test against under that share.
A simple
Test-Path "\\$_\C`$\Users"
would lead to false negatives if the machine is turned off or otherwise not accessible.
Thanks I will test it.... WinRM is required ino rder to run this correct?
Nope; as I said, just the regular admin shares. No remoting involved.