Different kinds of Powershell?


  1. Posts : 253
    64-bit Windows 10 Home ver.1607
       #1

    Different kinds of Powershell?


    I've recently used Powershell, but there appear to be several different versions of this utility. Some of them work--some of them merely report not being able to find something or call up something else. For instance, when I call up Powershell from an elevated command prompt, Powershell does not let me use a script to retrieve the chkdsk log. However, when I click the search button and bring up Windows Powershell (x86), Powershell appears in a dark-blue window and does work when I paste the same command. And it seems these versions of Powershell are located in different places.



    So what are the differences between these apparent different versions of Powershell?
    Attached Thumbnails Attached Thumbnails Different kinds of Powershell?-powershell2.png   Different kinds of Powershell?-powershell3.png  
      My Computer


  2. Posts : 17,661
    Windows 10 Pro
       #2

    The reason you can at the moment not run your scripts when running PowerShell (PS) from Command Prompt (CP) is most probably the execution policy set by the system; by default it is restricted. You need to launch the PS in CP with the ExecutionPolicy switch telling what kind of policy you want to be used, for instance Unrestricted. As I have changed the policy earlier, for this screenshot below I deliberately set it first to Restricted to show you an example:

    Different kinds of Powershell?-2015_10_05_22_07_472.png

    • #1 = Checking the current execution policy, noticing it's Restricted. Exiting PS
    • #2 = Launching the PS again, this time setting the policy to Unrestricted
    • #3 = Checking the current execution policy again, now it is Unrestricted.

    The ISE (Integrated Script Editor) version of the PS is just PS on steroids . You can for example open multiple tabs and do some other stuff not possible in the traditional PS (click the screenshot to enlarge):

    Different kinds of Powershell?-2015_10_05_21_59_371.png

    The x86 versions of PS and PS ISE are what the name says, 32 bit versions made available on 64 bit Windows. Basically they are useless for you, I have difficulties to think even a single scenario where you would need a 32 bit PS instead of a 64 bit in modern Windows.

    By the way, as you are interested in PowerShell, did you know that with it you can install most of your software, install all applications with one command, silently in the background without any user interaction, without any "Click Next", "Click Install", "Click this", "Would you also like to install that" and without any unwanted content being installed? Check the tutorial: PowerShell OneGet - Install Apps from Command Line - Windows 10 Forums

    Kari
      My Computer


  3. Posts : 253
    64-bit Windows 10 Home ver.1607
    Thread Starter
       #3

    Thank you, Kari, for this explanation. I've set the execution policy to unrestricted (I confirmed that after the initial command wouldn't work), but I can't get this command--get-winevent -FilterHashTable @{logname="Application"; id="1001"}| ?{$_.providername –match "wininit"} | fl timecreated, message | out-file Desktop\CHKDSKResults.txt--to work when I bring up PS from an elevated CP, even with the policy is set to unrestricted. It does work, however, in Powershell ISE (x86) and Powershell x86. Any idea why? Thanks again.
    Attached Thumbnails Attached Thumbnails Different kinds of Powershell?-powershell2.png  
      My Computer


  4. Posts : 3,257
    Windows 10 Pro
       #4

    This is very simple. When you run Powershell in an administrative prompt, your "current directory" defaults to C:\Windows\System32

    When you run it from an icon, it's not running in administrative mode, and the default "current directory" is your user profile..

    There is no "Desktop" directory under C:\Windows\System32, which is what the error is telling you. You're telling it to output to a file that cannot exist because the directory does not exist. There is, however, a desktop directory in your user profile.

    If you look closely at the error, it tells you exactly what the problem is. "DirectoryNotFoundException"
      My Computer


  5. Posts : 253
    64-bit Windows 10 Home ver.1607
    Thread Starter
       #5

    This is very simple. When you run Powershell in an administrative prompt, your "current directory" defaults to C:\Windows\System32

    When you run it from an icon, it's not running in administrative mode, and the default "current directory" is your user profile..

    There is no "Desktop" directory under C:\Windows\System32, which is what the error is telling you. You're telling it to output to a file that cannot exist because the directory does not exist. There is, however, a desktop directory in your user profile.

    If you look closely at the error, it tells you exactly what the problem is. "DirectoryNotFoundException"
    Thank you, Mystere. So is it then possible to change the directory so that PS works in my administrative prompt? Or do I change the command to reflect the current directory?
      My Computer


  6. Posts : 17,661
    Windows 10 Pro
       #6

    Just edit your command by changing the path where the file will be written. At the end of the command line you have now path as Desktop\CHKDSKResults.txt.

    Change it as you wish, for instance
    C:\Users\YourUserProfileName\Desktop\CHKDSKResults.txt would write the file to your desktop.
      My Computer


  7. Posts : 253
    64-bit Windows 10 Home ver.1607
    Thread Starter
       #7

    Thanks, Kari. Works perfectly!
      My Computer


  8. Posts : 17,661
    Windows 10 Pro
       #8

    You are welcome :)
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 07:43.
Find Us




Windows 10 Forums