locked
Windows 10 running previous PowerShell scripts is crashing RRS feed

  • Question

  • OK so I put 10 on my computer because it is pretty and now I may need to go back to 8.1 :-(

    The first script I ran with 10 on my PC which searches for a virtual machine by a keyword failed.

    The error is below.

    Enabling PS remoting on all the servers we have is not even remotely possible.

    I was running 4.5 and the early release of 5.0 on my laptop and desktop under 8.1 and it worked fine .

    Is there a way to get the compatible modules it ask for?

    Thanks

    Get-VM : The Hyper-V module used in this Windows PowerShell session cannot be used for remote management of the server 'MS01AHV53PF04'. Load 
    a compatible version of the Hyper-V module, or use Powershell remoting to connect directly to the remote server. For more information, see 
    http://go.microsoft.com/fwlink/p/?LinkID=532650.
    At C:\Users\9201401145\Google Drive\Scripts\PowerShell\LOOK FOR WHICH SERVER HAS A VIRTUAL MACHINE BY KEYWORD.PS1:29 char:1
    + Get-VM -ComputerName $server |Where-Object {$_.Name -like $lookfor}|S ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [Get-VM], VirtualizationException
        + FullyQualifiedErrorId : InvalidOperation,Microsoft.HyperV.PowerShell.Commands.GetVM


    Lishron

    Friday, September 11, 2015 11:50 AM

Answers

  • The solution to this issue was Windows 10 enterprise (at least all of ours in the office) has two different versions of hyper-v modules.  

    By forcing the script to run in 1.1 when on the 10 machine all the hyper-v related scripts now work.

    This is the line of code added 

    try {import-Module C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Hyper-V\1.1\Hyper-V.psd1 -ErrorAction Stop} catch {}


    Lishron

    • Marked as answer by Lishron Thursday, September 17, 2015 11:06 AM
    Thursday, September 17, 2015 11:06 AM

All replies

  • Works fine on my Windows 10 system.


    \_(ツ)_/

    Friday, September 11, 2015 12:00 PM
  • It worked great on 8.1 with.net 4.5 on my laptop and .net 5.0 preview on my desktop.

    I went to 10 yesterday and now today I get the error above.

    Below is the script.

    I will also do screen shot of what services I have enabled.

    #Get-VM -ComputerName MS01AHV51QA02 |Where-Object {$_.Name -like "*dfs*"}|Select-Object ComputerName,name,State,MemoryAssigned,Uptime |Format-Table
    
    
    $HV = (get-adcomputer -Filter 'name -like "*AHV*"' | select name)
    try{Remove-Item $env:TEMP\workfile.csv -ErrorAction Stop} catch {}
    foreach ($pc in $hv) {
    $pc = $pc -replace " ","" -replace "@{NAME=","" -replace "}",""
    
    Try {Get-Service  -ComputerName $pc | Where-Object {$_.DisplayName -like "Hyper-V Virtual Machine Management"} | select MachineName,DisplayName |export-csv $env:TEMP\workfile.csv -NoTypeInformation -Append} catch {"Not autherized for $PC"}
    
    }
    
    $workfile = Import-Csv $env:TEMP\workfile.csv | Sort MachineName 
    Clear-host
    
    $workfile.MachineName
    
    $keyword = Read-Host "
    
    
    
    
    What keyword do you want to seach for?"
    $lookfor = "*$keyword*"
    
    foreach ($server in $workfile.MachineName) {
    
    
    Get-VM -ComputerName $server |Where-Object {$_.Name -like $lookfor}|Select-Object ComputerName,name,State,MemoryAssigned,Uptime |Format-Table -HideTableHeaders
    
    }


    Lishron

    Friday, September 11, 2015 12:09 PM

  • Lishron

    Friday, September 11, 2015 12:13 PM
  • Windows 10 uses VM.  The error you are getting says the remote machine has an issue.  Perhaps firewall or permissions.


    \_(ツ)_/

    Friday, September 11, 2015 12:27 PM
  • I used this just last week. Still I am sure I can find someone here with 8.1 to test this on to see if that is the case.

    Thanks


    Lishron

    Friday, September 11, 2015 12:41 PM
  • Just used a coworkers 8.1 desktop and it worked fine. Just like it should. 


    Lishron

    Friday, September 11, 2015 12:57 PM
  • A Windows 8.1 system with the preview of WMF 5 then upgraded to Windows 10 will have many issues with PowerShell.  Remove the WMF 5 preview before installing Windows 10.

    I have just verified this on one 10 upgrade and amnow testing with an upgrade that did not have WMF 5 installed.


    \_(ツ)_/

    Friday, September 11, 2015 1:25 PM
  • I did a fresh install not upgrade.

    I have now ran it on 2 Win 10 machines both with fresh installs and 2 8.1 machines.

    Both 10 machines have given the same error.

    Both 8 machines worked fine.


    Lishron

    Friday, September 11, 2015 1:37 PM
  • I formatted the disk and did a full install. I kept nothing


    Lishron

    Friday, September 11, 2015 1:40 PM
  • You have a single machine that has a problem but nobody else can reproduce.

    I'm afraid that we're not going to be able to solve this break/fix from afar, sight unseen, in a forum.

    This is a free peer-to-peer scripting Q&A forum that has no SLA. If you require assistance to fix, you may need to hire a consultant or open a ticket with Microsoft.


    -- Bill Stewart [Bill_Stewart]

    Friday, September 11, 2015 2:12 PM
  • More then understand and I do applicate your time.

    It is not a single machine however the windows 10 machines we have done as a test all have the same issue.

    The 8.1 machines do not,

    Still I think we do have Microsoft support so that may be a good rout. Also I may be mistaken I thought JRV was able to reproduce it. 

    Thank you all again.


    Lishron

    Friday, September 11, 2015 2:18 PM
  • I cannot reproduce your issue because you have not really been clear as to what it is. You say "it" doesn't work but fail to define what "it" is.

    I noted above that there are issues with upgrades of WMF 5 preview on 8.1

    Win 10 WMF uses CimSessions.  Earlier PS VM used WMI.  They are cross compatible but we need to understand the security and protocol schemes. 

    I do not get the error you are getting.  On the machine upgraded from 8.1 with WMF 5 preview I do get the error.


    \_(ツ)_/


    • Edited by jrv Friday, September 11, 2015 3:08 PM
    Friday, September 11, 2015 3:04 PM
  • the error I get it below. I have mine and another user we both did fresh installs of windows 10 not upgrades.  We formatted the disk and did the upgrade.

    My laptop is giving the same error as well.   it is a fresh install of 10.

    We have windows 10 enterprise. 

    I understand you are trying and I do thank you for any assistance.

    Get-VM : The Hyper-V module used in this Windows PowerShell session cannot be used for remote management of the server 'MS01AHV53PF04'. Load 
    a compatible version of the Hyper-V module, or use Powershell remoting to connect directly to the remote server. For more information, see 
    http://go.microsoft.com/fwlink/p/?LinkID=532650.
    At C:\Users\9201401145\Google Drive\Scripts\PowerShell\LOOK FOR WHICH SERVER HAS A VIRTUAL MACHINE BY KEYWORD.PS1:29 char:1
    + Get-VM -ComputerName $server |Where-Object {$_.Name -like $lookfor}|S ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [Get-VM], VirtualizationException
        + FullyQualifiedErrorId : InvalidOperation,Microsoft.HyperV.PowerShell.Commands.GetVM


    Lishron

    Friday, September 11, 2015 4:09 PM
  • Your error message is this:

    The Hyper-V module used in this Windows PowerShell session cannot be used for remote management of the server 'MS01AHV53PF04'. Load a compatible version of the Hyper-V module, or use Powershell remoting to connect directly to the remote server. For more information, see http://go.microsoft.com/fwlink/p/?LinkID=532650

    Seems pretty clear. You're trying to manage a remote computer with the wrong version of the cmdlet.


    -- Bill Stewart [Bill_Stewart]

    Friday, September 11, 2015 4:16 PM
  • My previous post was designed as a hint to help you research.

    Try searching for the error message:

    http://www.google.com/search?&q=The+Hyper-V+module+used+in+this+Windows+PowerShell+session+cannot+be+used+for+remote+management

    Lots of information about that error, as you can see.


    -- Bill Stewart [Bill_Stewart]

    Friday, September 11, 2015 4:20 PM
  • Guys thank you all.
    Please don't take this wrong.  I do believe you may be frustrated with the belief that folks like me just come here ask and never research the issue first.
    I have been to these sites. You ask me to research and read yet I wonder if either of you read my question.
    I know this is volunteer and thanks for trying but please don't assume the worst most of us have done the best we can and use you as a last resource.


    JRV you said and I quote "I cannot reproduce your issue because you have not really been clear as to what it is. You say "it" doesn't work but fail to define what "it" is"
    I clearly posted the exact error in my first post.

    Bill you assume I have not googled this of course I have.  The articles I am reading that you just suggested in the same search I did state use ps remoting.   I clearly said very first post top of page that is not an option for all of our servers.

    I hope not to make you mad as I know I make mistakes and perhaps I do not see the solution you are trying to "hint" at.

    I gave the error I said cant enable remoting so if you don't know a way around making that happen instead of having me or some other shlub poking at a google search just don't answer or read the question and say you can’t do that.


    Once again I have no hostility as I type and I do thank you for your time.


    • Edited by Lishron Friday, September 11, 2015 6:55 PM
    Friday, September 11, 2015 6:54 PM
  • If you have searched, then you already know that there is no magical solution to your problem; only workarounds as stated. In any case, this is a Hyper-V question, not a scripting question.


    -- Bill Stewart [Bill_Stewart]

    Friday, September 11, 2015 7:08 PM
  • I only came here as I respect you knowledge thinking perhaps you had a solution.

    If you are saying this is the last place to come for info as most others are far better than then net forums I do understand. 

    And if everything works fine in hyper v except as related to powershell then this is every bit a fair place to ask such a question.

    On my laptop I have kept 10 in hopes MS will fix this issue however on my desktop it is back to 8.1 and all is working fine.

    Thanks


    Lishron

    Friday, September 11, 2015 7:28 PM
  • JRV you said and I quote "I cannot reproduce your issue because you have not really been clear as to what it is. You say "it" doesn't work but fail to define what "it" is"
    I clearly posted the exact error in my first post.


    You have not told us what is connecting to what. You have only noted which OS you were having errors on. must describe the whole scenario of the failure.  We cannot guess at what these things are.  Science is and exact science and reporting is not rocket science it is just good observation and recording.


    \_(ツ)_/

    Friday, September 11, 2015 7:35 PM
  • I only came here as I respect you knowledge thinking perhaps you had a solution.

    If you are saying this is the last place to come for info as most others are far better than then net forums I do understand. 

    And if everything works fine in hyper v except as related to powershell then this is every bit a fair place to ask such a question.

    On my laptop I have kept 10 in hopes MS will fix this issue however on my desktop it is back to 8.1 and all is working fine.

    Thanks


    Lishron


    Hyper-V is changed in10.  The Hyper-V forum is more likely to have people who have experience with the change and its behaviors.  The CmdLets are written by the Hyper-V people and are specific to a product. 

    \_(ツ)_/

    Friday, September 11, 2015 7:37 PM
  • Hmm

    I put the script in its entirety.

    I put the error message in its entirety.

    I put the OS.

    I put the .net framework.

    I put windows features I had installed.

    Do you need video?


    Lishron

    Friday, September 11, 2015 7:39 PM
  • You are still missing the point.  A connection includes two endpoints.  What are the endpoints and how are BOTH configured.  You only ever give the source and at times hint at the target.  Build a matrix of connections and errors along with OS, PS version, remoting config.

    There are many causes of this error.  You  ned to start with a clear description then look for matches in the reports and solutions.

    If you are not in a domain or are on a wireless net then all bets are off.  Read the reports posted by Bill.


    \_(ツ)_/

    Friday, September 11, 2015 7:43 PM
  • Am I on a network?   Hmmmmmm

    You are stretching

    I guess out of habit I come here and always hope there is new folks.  I know I could answer a few of these questions better then you just for the fact I can read a problem and eliminate X Y and Z.  You have GREAT knowledge that is unmatched by many and educate so many but we all have our short comings. Lord knows I do.  

    Still I don't have the time and I do recognize you are volunteering yours so I will say thank you.

    I will not close out the issue as there is no solution to my problem at this time but feel free to do so if it must be.

    I do thank you very much and have a good weekend


    Lishron

    Friday, September 11, 2015 8:00 PM
  • I did not say network I posted "domain".  Not the same thing.  I also noted that wireless links are an issue that has also been noted and not resolved.\

    I do not understand why you won't post what you connections are.  Why is it a secret?


    \_(ツ)_/

    Friday, September 11, 2015 8:04 PM
  • The solution to this issue was Windows 10 enterprise (at least all of ours in the office) has two different versions of hyper-v modules.  

    By forcing the script to run in 1.1 when on the 10 machine all the hyper-v related scripts now work.

    This is the line of code added 

    try {import-Module C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Hyper-V\1.1\Hyper-V.psd1 -ErrorAction Stop} catch {}


    Lishron

    • Marked as answer by Lishron Thursday, September 17, 2015 11:06 AM
    Thursday, September 17, 2015 11:06 AM