Overriding secuirty with get-childitem

Welcome Forums General PowerShell Q&A Overriding secuirty with get-childitem

This topic contains 3 replies, has 3 voices, and was last updated by

 
Participant
2 weeks, 1 day ago.

  • Author
    Posts
  • #174811

    Participant
    Topics: 5
    Replies: 4
    Points: 14
    Rank: Member

    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

  • #174844

    Participant
    Topics: 1
    Replies: 1530
    Points: 2,591
    Helping Hand
    Rank: Community Hero

    ... But the PS script, when put in a job will likely need to run under another id.

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

    ... or did I miss something again? 😉

  • #174883

    Participant
    Topics: 6
    Replies: 78
    Points: 143
    Helping Hand
    Rank: Participant
    • 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
  • #174994

    Participant
    Topics: 5
    Replies: 4
    Points: 14
    Rank: Member

    Thanks Charles. I will do that.

    MG

You must be logged in to reply to this topic.