Jump to content

Recommended Posts

Posted
Don't run it with ISE... I always create a .ps1 file and execute that. I have loads of PS scripts I've created and as long as I test/debug them correctly I've not run into any issues. I don't see it as an issue but I'm no powershell guru.
  • Thanks 1
Posted

HI Jaminben,

 

Brilliant, worked perfectly as a .ps1 script!

 

Any chance, you can help with me one other thing?

Is there a way to get a log file or something that shows whats been deleted etc......

 

Thanks again, Much appreciated!

Posted
Can't remember the code off the top of my head but Google "powershell out-file" and add it to your loop... I can supply an example on Friday if you've not sorted it by then.
  • Thanks 1
Posted

ok, i got the code

 

| Out-File 'C:\results.log'

 

which i have put at the end of the script.

 

it creates the log file, but the file is empty.

 

any ideas?

 

thanks again.

Posted

Add the below to your loop:

 

$textToLog = "AccountName: " + $_.samaccountname,"`r`nHome Directory: " + $_.HomeDirectory,"`r`nProfile Path: " + $_.profilepath
$textToLog | Out-File -Append "C:\yourfilename.log"

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...