Jump to content

Script to report folders in C:\users and store results centrally?


Recommended Posts

Posted

Has anyone come across a script which can be run at startup which would report the contents of C:\users and save the results centrally?

 

I've changed the location of my redirected desktops this summer and want to ensure the script I've run at startup has actually worked and cleaned out all the local profiles, it appears on some machines it's not worked :(

Posted

This powershell script might work!

 

Get-ChildItem -Path C:\users | Out-File \\dc01\netlogon\uc\$env:computername.txt

 

But got to work out how to run the script at startup!

Posted

I've got the script running...

 

but it can't write the results back :(

 

Error Message = Access to the path '\\fp4\d$\Server_Apps\Utilities\pcaudit\uc\TEMP00-2019-08.txt' is denied.

Fully Qualified Error ID = FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand

 

 

I've added "Domain Computers to the folder "\\fp4\d$\Server_Apps\Utilities\pcaudit\uc" with full control...

Posted
I've got the script running...

 

but it can't write the results back :(

 

Error Message = Access to the path '\\fp4\d$\Server_Apps\Utilities\pcaudit\uc\TEMP00-2019-08.txt' is denied.

Fully Qualified Error ID = FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand

 

 

I've added "Domain Computers to the folder "\\fp4\d$\Server_Apps\Utilities\pcaudit\uc" with full control...

 

How do you have it running now? Login scripts run under user credential and startup scripts run under local computer credentials.

 

Might be easier to run a batch script with something like this:

 

net use z: \\dc01\netlogon\uc /user:username /password:password
dir C:\users > z:\%computername%.txt
net use z: /delete

 

...or as recommended earlier using a scheduled task at startup as you can pass alternate credentials to that as well.

Posted
How do you have it running now? Login scripts run under user credential and startup scripts run under local computer credentials.

 

Might be easier to run a batch script with something like this:

 

net use z: \\dc01\netlogon\uc /user:username /password:password
dir C:\users > z:\%computername%.txt
net use z: /delete

 

...or as recommended earlier using a scheduled task at startup as you can pass alternate credentials to that as well.

 

I need ideally it to run without having to logon so I've got it running as a startup script.

 

I've set the NTFS permissions on the folder I need the file to be created in to include "Domain Computers" : Full Control.

Posted

Sorted.

 

I saved the file locally and then used this line:

 

Copy-Item -Path D:\folder\test.txt -Destination \\server1\remoteshare\

 

and made sure the share had write permissions for Authenticated Users and Domain Computers on both the share and the folder.

 

Might look at changing the script now so it counts the number of folders in C:\users as well!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...