locked
Powershell question RRS feed

  • Question

  • Good Morning,

    I am new to powershell and I did a few mistakes when running commands or testing and that is that powershell didn't warn me like if you run this command that will happen. Is there a way to see what will certan command do if I run it?

    Friday, September 22, 2017 6:07 AM

Answers

  • Hi,

    Yes, you will need to use -whatif. You will see the result of the command without running it.

    Example

    Get-Service VSS | Stop-Service -WhatIf 
    Result

    What if: Performing the operation "Stop-Service" on target "Volume Shadow Copy (VSS)".

    Use -confirm if you want to get warning like "Are you sure you want to perform this action?"

    Please remember to mark the replies as answers if they help.,

    NEDIMMEHIC.ORG

    • Proposed as answer by jrv Friday, September 22, 2017 7:04 AM
    • Marked as answer by TeJones Friday, September 22, 2017 7:27 AM
    Friday, September 22, 2017 6:11 AM
  • I would recommend that you take a look at this first before you move forward.

    https://mva.microsoft.com/en-us/training-courses/getting-started-with-microsoft-powershell-8276?l=r54IrOWy_2304984382

    Next you will need to learn how to use get-help or just help, get-command and get-member. Those 3 commands will be your best friends.

    I would recommend that you put focus on objects. That is probably one of the most important concepts in understanding and knowing how powershell works. If you don't learn it or if you struggle with that please try to go back and repeat it until it sinks in. If you don't get the content and the ideas , you will have a very big problem and you will hate it.

    Be sure to learn pipeline because powershell works with objects in a pipeline. Put focus on these Select, Sort, Group, Where and Measure

    Please remember to mark the replies as answers if they help.,

    NEDIMMEHIC.ORG

    • Marked as answer by TeJones Friday, September 22, 2017 7:27 AM
    Friday, September 22, 2017 6:31 AM

All replies

  • Thank you, thank you, that was exactly what I am looking for. I am still learning and testing powershell but I think that powershell is very hard and confusing part. I watched some youtube videos but cannot get the core or it is very hard to understand. Any advices are welcome on how to learn or how to understand it before it comes to the part like I hate it and I don't want to use it.
    Friday, September 22, 2017 6:20 AM