0

Im just getting started with Powershell and im starting to get the hang of it. Im currently working on a script where i would like to run different things in parallel. For example i would like to capture some performance statistics in the background while some other things are running. So i found this great cmdlet called Start-Job that would do exactly what i want to do. So i created a small script with a Get-Counter to gather performance data. The command run fine on its own. But when i try to run it as a Job i get a popup with a "How do you want to open this file". If i choose notepad, i get nothing it it and the job runs without any data.

It looks like it happends everytime i try to run Get-Counter insdie the scriptblock statement. Other things work for some reason. Any help would be appritiated.

Example. This Works:

start-job -ScriptBlock {Get-ChildItem} 

This does not work

start-job -ScriptBlock {Get-Counter} 

Im guessing there are some kind of permissions i need or or is there something about Start-Job that i dont understand?

2
  • Please provide more detail on your Get-Counter command. This works just fine. Start-Job -ScriptBlock {Get-counter '\Process(*)\% Processor Time'} Commented Oct 13, 2020 at 22:06
  • As i stated above. It doesnt even work when i run Get-Counter as a job. If i run youtr command i ghet the same issue. I get a popup asking me to select a program to open something. Commented Oct 14, 2020 at 8:59

1 Answer 1

1

Haha well im a bit embarrassed to say this but i found the solution by myself. So if anyone else is having issues with getting the "How do you want to open this file?"-message. It turned out that i had accidently created an empty file in C:\Windows\System32 called "Get-Counter" (with no file extension). So every time i tried to run the "Get-Counter" command, it tried to open my empty file... I just removed the file and everything started working again.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.