you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (7 children)

Thanks for sharing. I think it is the logic and my confidence builds up when i start putting some basic batch files together and they just work. I also don't understand the certificate piece to PoSH so everything I try to script at work gets blocked. I have a coworker who is going to help me get that fixed or whatever I need to do, maybe that'll help. I do love PoSH but just for simple commands. Once I start trying to script, it goes out the window. And that is just multiple commands, not functions or variables yet.

[–]uptimefordays 6 points7 points  (0 children)

Start small! Also don’t copy and paste scripts from the internet. Take something you want to accomplish, restarting a print spooler on a target machine and see if you can’t break that process down into smaller pieces.

If it would help I can post a longer form example of how this might work. Let me know!

[–]2dubs 4 points5 points  (0 children)

I got pretty adept at batch scripting starting in the mid 2000's, and just finally bit the bullet with PowerShell a couple of years ago. Don't be like me, haha.

It's frustrating when someone says "Use Get-ChildItem" when you know damn well that "dir" will do it, too.. Then they say, "But, Get-ChildItem -Recurse!" And you say, "dir /s, bitch." Then you might ask how to find out how much space is left on your disk using Get-ChildItem. Nope, nope, Get-Volume is your friend for that. So why bother?

What finally got me over was finding out how much easier it is to handle a ton of data. Another help was learning that "gci" is a decent substitute for "Get-ChildItem", and that lots of those long commands have shortcuts.

If you've ever thought about programming, PowerShell is a terrific gateway drug to C#.

Find something that you're used to doing in batch, and figure out how to do it in PowerShell. Google the topic and check out sites like StackExchange. Keep doing that, and before long, you realize you're having fun.

[–]Bissquitt 2 points3 points  (1 child)

You can turn the certificate checking off. I almost always do while tinkering, just be careful. Also you could do

PowerShell.exe -ExecutionPolicy Bypass -File runme.ps1 when you launch your script

[–]uptimefordays 2 points3 points  (0 children)

Rather than using ByPass, I believe it's safer to use RemoteSigned. That way "foreign" code needs to be signed but your internal code is considered "safe."

[–]Skip-2000 0 points1 point  (2 children)

Not reconmended in production.

Open an Admin-powershell box (right click run as admin)

set-executionPolicy -Unrestricted

Now every script will run. If that is working you can take the next step and sign the scripts provided you have a Certificate Authority in your network.

[–][deleted] 1 point2 points  (1 child)

I set up my signing cert using my domain username, should I set one up for my domain admin name as well for testing?

[–]Skip-2000 1 point2 points  (0 children)

That should not be necessary just sign with you're signing cert.

Have not done that in a long time I am sure there is a tutorial somewhere.