Since update to PS Studio 2018 some powershell modules failing on load form startup.pss

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
MDinice
Posts: 20
Last visit: Sun Feb 19, 2023 4:27 pm

Since update to PS Studio 2018 some powershell modules failing on load form startup.pss

Post by MDinice »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: PowerShell Studio 2018 v5.5.148
32 or 64 bit version of product: 64 bit
Operating system: Win 10
32 or 64 bit OS: 64 bit

*** Please add details and screenshots as needed below. ***

DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM

Since the upgrade last night to PS Studio 2018 my module calls are erroring out

>> Running (365EAC.psproj) Project Script...
>> Building (365EAC) Project...
>> Merging 'Startup.pss' ...
>> Merging 'Globals.ps1' ...
>> Merging 'frmMain.psf' ...
>> Merging 'subfrmAbout.psf' ...
>> Merging 'subfrmProperties.psf' ...
>> Merging 'subfrmMainLicensing.psf' ...
>> Merging 'subfrmSubLicensing.psf' ...
>> Writing '365EAC.Run.ps1' ...
>> Platform: V5 32Bit (STA) (Forced)
-2147024891

VERBOSE: Loading Exchange Management shell...

VERBOSE: Loading On-Prem AD Module...

VERBOSE: Loading MsOnline Module...
ERROR: Get-MsolDomain : The term 'Get-MsolDomain' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
ERROR: name, or if a path was included, verify that the path is correct and try again.
Startup.pss (62, 5): ERROR: At Line: 62 char: 5
ERROR: + Get-MsolDomain -ErrorAction SilentlyContinue | Out-Null
ERROR: + ~~~~~~~~~~~~~~
ERROR: + CategoryInfo : ObjectNotFound: (Get-MsolDomain:String) [], CommandNotFoundException
ERROR: + FullyQualifiedErrorId : CommandNotFoundException
ERROR:

VERBOSE: Connecting to MSOL Service...
ERROR: Connect-MsolService : The term 'Connect-MsolService' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling
ERROR: of the name, or if a path was included, verify that the path is correct and try again.
Startup.pss (148, 3): ERROR: At Line: 148 char: 3
ERROR: + Connect-MsolService -Credential $Creds # Connect to AzureAD
ERROR: + ~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : ObjectNotFound: (Connect-MsolService:String) [], CommandNotFoundException
ERROR: + FullyQualifiedErrorId : CommandNotFoundException
ERROR:

VERBOSE: Connecting to Azure AD...
ERROR: Connect-AzureAD : The term 'Connect-AzureAD' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
ERROR: name, or if a path was included, verify that the path is correct and try again.
Startup.pss (154, 3): ERROR: At Line: 154 char: 3
ERROR: + Connect-AzureAD -Credential $Creds
ERROR: + ~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : ObjectNotFound: (Connect-AzureAD:String) [], CommandNotFoundException
ERROR: + FullyQualifiedErrorId : CommandNotFoundException
ERROR:
VERBOSE: Importing Exchange Online Cmdlets...
ERROR: Get-AzureADSubscribedSku : The term 'Get-AzureADSubscribedSku' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
ERROR: the spelling of the name, or if a path was included, verify that the path is correct and try again.
frmMain.psf (39, 31): ERROR: At Line: 39 char: 31
ERROR: + $varArrSubLicSkuIdPartNums = Get-AzureADSubscribedSku | Selec ...
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : ObjectNotFound: (Get-AzureADSubscribedSku:String) [], CommandNotFoundException
ERROR: + FullyQualifiedErrorId : CommandNotFoundException
ERROR:
ERROR: Exception calling "Add" with "2" argument(s): "Key cannot be null.
ERROR: Parameter name: key"
frmMain.psf (45, 3): ERROR: At Line: 45 char: 3
ERROR: + $htSubLicSkuIdPartNumData.add($_.SkuId,$_.SkuPartNumber)
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
ERROR: + FullyQualifiedErrorId : ArgumentNullException
ERROR:
ERROR: Exception calling "Add" with "2" argument(s): "Key cannot be null.
ERROR: Parameter name: key"
frmMain.psf (63, 4): ERROR: At Line: 63 char: 4
ERROR: + ... $htSubLicPlanSkuIdPartNumData.add($_.ServicePlanId,$_.Ser ...
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
ERROR: + FullyQualifiedErrorId : ArgumentNullException
ERROR:

I run the same code natively in a PS profile and it completes successfully


VERBOSE: Loading Exchange Management shell...
WARNING: The names of some imported commands from the module 'tmp_1uc4ppii.spz' include unapproved verbs that might
make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the
Verbose parameter. For a list of approved verbs, type Get-Verb.

VERBOSE: Loading On-Prem AD Module...

VERBOSE: Loading MsOnline Module...

VERBOSE: Connecting to MSOL Service...

VERBOSE: Connecting to Azure AD...

Account Environment TenantId TenantDomain AccountType
------- ----------- -------- ------------ -----------
xxxxxxx@xxxx.xxx AzureCloud dd8cbebb-2139-4df8-b411-4e3e87abeb5c xxxx.xxx User


Loading personal and system profiles took 51779ms.
PS C:\Users\xxxxxxx\Documents\WindowsPowerShell\Scripts>

This is the code I use in both PS profile and Startup.pss. the creds file is

$Global:Credsfile = "$env:UserProfile\Documents\WindowsPowerShell\Creds\CREDaoEDU.xml"

If(($CredsFile) -and (Test-Path $CredsFile)) {
$Global:Creds = Import-Clixml $CredsFile # Use the creds file if user specified it
} Else {
# Prompt for credentials
$Global:Creds = Get-Credential
}

# Function to check if MSOLService is connected
Function MSOLConnected {
Get-MsolDomain -ErrorAction SilentlyContinue | Out-Null
$Result = $?
Return $Result
}

Function Main {
#----------------------------------------------
#region Main Startup Function
#----------------------------------------------
<#
.SYNOPSIS
The Main function starts the project application.

.PARAMETER Commandline
$Commandline contains the complete argument string passed to the script packager executable.

.NOTES
Use this function to initialize your script and to call GUI forms.

.NOTES
To get the console output in the Packager (Forms Engine) use:
$ConsoleOutput (Type: System.Collections.ArrayList)
#>

Param ([String]$Commandline)

#--------------------------------------------------------------------------
#TODO: Add initialization script here (Load modules and check requirements)
#----------------------------------------------
#region Load PowerShell Modules
#----------------------------------------------

# --------------------------------------------------
# Load the Exchange module. If not already Loaded
If((Get-Command Get-RemoteMailbox -ErrorAction SilentlyContinue) -eq $Null) {
Write-Host ""
Write-Verbose "Loading Exchange Management shell..." -Verbose

#. 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1' # leading dot on this line is NOT a typo
#Connect-ExchangeServer -Auto -ClientApplication:ManagementShell

$Creds = Import-Clixml $CredsFile
$exchLocSessionEDU = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://o365toolbox.yu.yale.edu/powershell -Credential $Creds -Authentication Kerberos

#Import-PSSession $exchLocSessionEDU | Out-Null
Import-PSSession $exchLocSessionEDU -CommandName Get-User,Get-Mailbox,Get-RemoteMailbox,Enable-RemoteMailbox,Remove-RemoteMailbox,Send-MailMessage | Out-Null
} Else {
Write-Host ""
Write-Verbose "Exchange Management shell already loaded..." -Verbose
}
$errStartupHandler = Get-Mailbox DiscoveryMailbox

$getDisplayName = Get-User $User | Select DisplayName
$varDisplayName = $getDisplayName.DisplayName #>

# --------------------------------------------------
# Load Local AD Module. If not already Loaded
If((Get-Module ActiveDirectory -ErrorAction SilentlyContinue) -eq $Null) {
Write-Host ""
Write-Verbose "Loading On-Prem AD Module..." -Verbose

Import-Module ActiveDirectory
} Else {
Write-Host ""
Write-Verbose "On-Prem AD Module already loaded..." -Verbose
} #>

# --------------------------------------------------
# Load MSOnline module. If not already Loaded
If((Get-Module MsOnline) -eq $Null) {
Write-Host ""
Write-Verbose "Loading MsOnline Module..." -Verbose

#Import-Module MSOnline
} Else {
Write-Host ""
Write-Verbose "MsOnline Module already loaded..." -Verbose
} #>

# --------------------------------------------------
# Connect to MSOL Service & Azure AD. If not already get connected
If(-Not (MSOLConnected)) {
Write-Host ""
Write-Verbose "Connecting to MSOL Service..." -Verbose

$Creds = Import-Clixml $CredsFile
Connect-MsolService -Credential $Creds # Connect to AzureAD

Write-Host ""
Write-Verbose "Connecting to Azure AD..." -Verbose

$Creds = Import-Clixml $CredsFile
Connect-AzureAD -Credential $Creds
} Else {
Write-Host ""
Write-Verbose "MSOL Service already connected..." -Verbose

Write-Host ""
Write-Verbose "Azure AD already connected..." -Verbose
} #>

# --------------------------------------------------
# Import the Exchange Online cmdlets if we haven't done so previously
# Commands will arrive prefixed with "o365" so you can distinguish
# onprem commands (get-mailbox) from cloud commands (get-o365mailbox)
If((Get-Command Get-O365mailbox -ErrorAction SilentlyContinue) -eq $Null) {
#Write-Host ""
Write-Verbose "Importing Exchange Online Cmdlets..." -Verbose

$Creds = Import-Clixml $CredsFile
$exchSessionEDU = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Creds -Authentication Basic –AllowRedirection

Import-PSSession $exchSessionEDU -prefix "O365" -CommandName Get-User,New-Mailbox,Get-Mailbox,Set-Mailbox,Get-CalendarProcessing,Set-CalendarProcessing,Get-MailboxFolderPermission,Add-MailboxFolderPermission,Remove-MailboxFolderPermission,Get-RecipientPermission,Add-RecipientPermission,Remove-RecipientPermission,New-DistributionGroup,Get-DistributionGroup,Set-DistributionGroup,Get-DistributionGroupMember,Add-DistributionGroupMember,Remove-DistributionGroupMember,New-MailContact,Get-MailContact,Set-MailContact,New-MailUser,Get-MailUser,Set-MailUser,Get-MsolUser,Set-MsolUser | Out-Null
} Else {
#Write-Host ""
Write-Verbose "Exchange Online Cmdlets already loaded..." -Verbose
}
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Since update to PS Studio 2018 some powershell modules failing on load form startup.pss

Post by davidc »

Looks like you are running the script in 32 bit. Set the platform to 64 bit and see if that resolved your issue.
David
SAPIEN Technologies, Inc.
User avatar
MDinice
Posts: 20
Last visit: Sun Feb 19, 2023 4:27 pm

Re: Since update to PS Studio 2018 some powershell modules failing on load form startup.pss

Post by MDinice »

Perfect, Thank you that did it. Would the upgrade have possibly changed that setting?
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Since update to PS Studio 2018 some powershell modules failing on load form startup.pss

Post by davidc »

It copies the settings from 2017 and PowerShell Studio retains the last platform selected when you open and close the product.
David
SAPIEN Technologies, Inc.
This topic is 6 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.