Welcome Forums General PowerShell Q&A #requires

This topic contains 4 replies, has 3 voices, and was last updated by

2 years, 8 months ago.

  • Author
  • #42141

    Points: 58
    Rank: Member

    I looked in the help about_requires I don't see anything about requiring that the console be launched in 64bit mode. is there a hidden requires statement perhaps? or is there a module that is only loaded in 64 bit powershell but not 32 bit that is common across all or several the versions? On this site (http://www.nivot.org/blog/post/2012/12/18/Ensuring-a-PowerShell-script-will-always-run-in-a-64-bit-shell) I found this snippet (below) is there something easier?

    if ($pshome -like "*syswow64*") {
        write-warning "Restarting script under 64 bit powershell"
        # relaunch this script under 64 bit shell
        # if you want powershell 2.0, add -version 2 *before* -file parameter
        & (join-path ($pshome -replace "syswow64", "sysnative") powershell.exe) -file `
            (join-path $psscriptroot $myinvocation.mycommand) @args
        # exit 32 bit script
  • #42226

    Points: 0
    Rank: Member

    As far as I'm aware there isn't a requires setting for 32/64 bit

    Most modules run OK in both. I know that some parts of the VMware module only work in 32 bit

    You can also test if running 32/64 bit like this

    if ([System.IntPtr]::Size -eq 8) {$size = '64 bit'}
    else {$size = '32 bit'}

  • #42293

    Points: 58
    Rank: Member

    The reason for the post was I ran into using this class from Dotnet and it couldn't be loaded when using the 32bit shell:

    $mgr = new-object Microsoft.Web.Administration.ServerManager

    After searching further found out that the script that was being called was initially being run in the 32bit shell. So wondered if there was some way I could make sure that the user only used 64 bit version of the shell. That is what prompted this post.

    Since this class is limited to instances of IIS I was looking for something that might have been in any 64 bit version of windows only..

  • #42296

    Points: 1
    Rank: Member


The topic ‘#requires’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort