1.    04 Oct 2015 #1
    Join Date : Jun 2015
    Florida
    Posts : 253
    64-bit Windows 10 Home ver.1607

    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 powershell2.png   powershell3.png  
      My ComputerSystem Spec
  2.    05 Oct 2015 #2
    Join Date : Oct 2013
    A Finnish expat in Germany
    Posts : 13,130
    Windows 10 Pro

    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:

    Click image for larger version. 

Name:	2015_10_05_22_07_472.png 
Views:	4 
Size:	104.2 KB 
ID:	41255

    • #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):

    Click image for larger version. 

Name:	2015_10_05_21_59_371.png 
Views:	6 
Size:	250.0 KB 
ID:	41251

    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 ComputerSystem Spec
  3.    05 Oct 2015 #3
    Join Date : Jun 2015
    Florida
    Posts : 253
    64-bit Windows 10 Home ver.1607
    Thread Starter

    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 powershell2.png  
      My ComputerSystem Spec
  4.    05 Oct 2015 #4
    Join Date : Sep 2014
    Nashville, TN
    Posts : 3,143
    Windows 10 Pro

    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 ComputerSystem Spec
  5.    06 Oct 2015 #5
    Join Date : Jun 2015
    Florida
    Posts : 253
    64-bit Windows 10 Home ver.1607
    Thread Starter

    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 ComputerSystem Spec
  6.    06 Oct 2015 #6
    Join Date : Oct 2013
    A Finnish expat in Germany
    Posts : 13,130
    Windows 10 Pro

    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 ComputerSystem Spec
  7.    06 Oct 2015 #7
    Join Date : Jun 2015
    Florida
    Posts : 253
    64-bit Windows 10 Home ver.1607
    Thread Starter

    Thanks, Kari. Works perfectly!
      My ComputerSystem Spec
  8.    06 Oct 2015 #8
    Join Date : Oct 2013
    A Finnish expat in Germany
    Posts : 13,130
    Windows 10 Pro

    You are welcome
      My ComputerSystem Spec

 


Similar Threads
Thread Forum
Solved How to uninstall Apps using Powershell
Many of the Universal Apps cannot be uninstalled because the button is inactive (grayed out). This might be 'by design' for the Technical Preview since Microsoft wants users to test the Apps. The preferred method is to use the uninstall button...
Customization
Solved How to use Powershell for simple CMD tools
I am by no standard a programmer. But in the past, I had a job with a lot of skutwork needed on a daily basis. I.T. was always too busy, and non-I.T. folks were not allowed to do any programming, but the command line and batch stuff was not real...
General Support
Hide powershell scrollbar.
Hello ! I scroll in my powershell using either sihft + arrow keys of pgup and pgdown. How can I disable the scrollbar ? I don't need it.
General Support
Powershell glitch
Hi fellow W10 users, This week I switched to using Windows 10, but I have this strange problem/glitch in PowerShell. At first I did an upgrade from Windows 8.1 to Windows 10, after which I did a full clean install. Now here it comes......
Software and Apps
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 10:00.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums