Overriding secuirty with get-childitem

Fellow Powershellers;

I am counting the number of files in a folder - simple. Kind of a loop- have an array of shared/folders.

when I run the ps script, I am admin. works great. But the PS script, when put in a job will likely need to run under another id.

That custom ID already exists with the permission to the folders.

So what is the best way to force security to us the custom id/password before it hits get-childitem

I would still like to stay with get-childitem.

Thanks MG

Why? Who is gonna start this job? That would be the context the script runs in.

… or did I miss something again? :wink:

  • Run Powershell console as that user
  • Run the script in a scheduled task that runs as that user
  • Use Start-Process to kick off the .ps1 as that user

Thanks Charles. I will do that.