#requires

Tagged: 

This topic contains 4 replies, has 3 voices, and was last updated by Profile photo of thom schumacher thom schumacher 3 months, 2 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #42141
    Profile photo of thom schumacher
    thom schumacher
    Participant

    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
        exit
    }
    
    #42226

    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
    Profile photo of thom schumacher
    thom schumacher
    Participant

    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
    Profile photo of Don Reese
    Don Reese
    Participant

    [Environment]::Is64BitProcess

    #42303
    Profile photo of thom schumacher
    thom schumacher
    Participant

    nice... thanx Don

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.