Why am I getting a prompt "run only scripts that you trust" when I'm running my scripts?

Just curious. It’s annoying. Everytime I try to run a script I wrote, I get a message “Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your computer.”

I wrote it. This particular script is 3 lines. I have another one that is much longer. But, I didn’t copy any code from any other sites. I get the same error for that script. I’ve gotten OK at writing scripts from scratch over the years. Nothing is plagarized. I’ve set my executionpolicy to unrestricted or whatever so I can run them period.

How exactly do you run this script?

This may help already:

I just run them by clicking the play button in ISE.

ok, i set the execution policy to bypass and it didn’t give me the error. thanks!

1 Like

OK. Where are they stored? On your local computer or on a network drive? Do you change them everytime before you run them? Why do you run them from the ISE?

If that’s the solution you’re satisfied with … great. :+1:t3: :slightly_smiling_face: :love_you_gesture:t3:

still wonder if that’s the right answer though. i mean, the execution policy is there to stop you from doing something bad. there has to be a way for me to run the script in a strict execution policy you’d think. something or some way I’d sign it to show I’m the good guy and gone through the ropes and loops to prove it so it will run with the default setting rather than lowering the security threshold to run it.

No. It’s not a security feature. You can circumvent it too easily. :wink:

But again … why do you actually run them in the ISE? Do you change them everytime you want to use them?

Did you review the StackOverflow thread I linked in my first answer?

I just run them from ISE because it’s convenient and I can make slight modifications easily as I notice things not working right. I do have some scripts I run on scheduled tasks and elsewhere. But, most scripts I write are to just a specific task done and, once it’s done, the script is deleted… I don’t have a lot of written scripts that I just run daily for a long term.

Professional-wise, it’s been a while. Personal computing stuff, I’ll just write it to save myself a ton of manual work, but it’s usually a once and done type thing. Or a project that will end after all the files are processed and the script will never have a use again for me…

Sounds like you’re running lines of code - not scripts. In the ISE you can select code and run only this selection with <F8> instead of running the entire script with <F5>. This way the message shouldn’t appear.

lines of code… script… same thing. I’m using variables and doing stuff with it which is resulting in the modification of hundreds of files. Only thing I guess I’d would think that would define this code as more of lines of code over a script is I’m not using any arrays or loops of any kind because it’s unnecessary in this code for what I’m doing. Technically it’s a script because it’s a .ps1 file running. But potatoes pototos tomatos tomotos.

I use the play button that has the paper on the background while highlighting lines usually when I’m debugging…

1 Like

I love programming. I am a struggling programmer. Been trying to figure it out for like 20+ years. But powershell is the furthest I’ve gotten into learning it. On the last team I was on, I was starting to make some pretty long scripts up to a hundred lines of code. Powershell was making all the stuff I read about other programming languages start to make sense to me. What I was posting about in this particular forum post are just little snippets of code I wrote to make my life easier.

On my off time, I’ve been dedicating my time to learning python. But, between learning c++, some java, c#, powershell, little java and shell scripting, the 101ish level I’ve learned from about everything, I’m seeing the pattern. I used to think c++ to java would be like learning french to russian. They’re completely different languages. But it’s not. You learn one and they all just make sense.

I really don’t like python. I wish it worked more like c# or powershell. I wish it was strongly typed and I wish it used more parenthesis to organize code. I hate how python is all organized by indentation. But, whatever. It seems to be the dominant scripting language these days for cloud computing, so I’m learning it.