Run job with elevated permissions

Need a little help and Google isn’t showing me any immediate answers. I have a small script that runs without elevated permissions, but it needs to start a background job that DOES require elevated permissions to work. my current (messy af) script looks something like this:

function func1 { $CommandThatNeedsAdmin } function func2 { start-job -name 'job' -scriptblock { func1 } } 

However after running get-job job it says the job has failed presumably since it requires elevated permissions, but doesn’t have them. Any insight on how to make this work?

Edit: I’m pretty new to PoSH, if you can’t tell. =)

submitted by /u/Ubuntu_Linux_User
[link] [comments]

Leave a Reply