Import-Module stops working sporadically - powershell

I have a problem where Import-Module -Name "./MyAssembly.dll" stops working sporadically. If I restart the computer, everything seems to work as normal for a while, but it's getting really frustrating.
The reason for importing the same module (in different Powershell sessions) is because I'm currently writing a cmdlet using C#, and I start a powershell instance as part of debugging the cmdlet.
The Import-Module command gives me no feedback whatsoever of whether or not the loading succeeded.
PS C:\Source\MyProject> Import-Module -Name "./MyAssembly.dll"
PS C:\Source\MyProject> Get-Stuffz
Get-Stuffz : The term 'Get-Stuffz' is not recognized as the name of a cmdlet, function, script file, or ope
rable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again
.
At line:1 char:1
+ Get-Stuffz
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-Stuffz:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Any help or suggestions are welcome.

Related

Why am I getting errors when trying to run Get-Transportconfig in a Powershell session?

I am trying to run Powershell to invoke Set-TransportConfig on my Exchange mailbox.
Windows Powershell ISE is running elevated as admin.
I am able to connect to Exchange:
Connect-ExchangeOnline -UserPrincipalName
When I attempt to run this command:
Get-TransportConfig -SmtpClientAuthenticationDisabled
I get the following error:
Get-TransportConfig : The term 'Get-TransportConfig' is not recognized
as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that
the path is correct and try again. At line:1 char:1
Get-TransportConfig -SmtpClientAuthenticationDisabled
+ CategoryInfo : ObjectNotFound: (Get-TransportConfig:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
If I run the following:
get-command *transportconfig*
It does not return any commands:.
I've tried running:
Import-Module ExchangeOnlineManagement
Install-Module ExchangeOnlineManagement
It does not return any errors or results (Does that mean it's correctly installed?)
Why can't I run the Get-TransportConfig command? What am I doing wrong here? Am I missing an additional library?

MSI install powershell program but no modules available

I installed AutomatedLab.msi from here - https://github.com/AutomatedLab/AutomatedLab/releases
it installed without any errors but there doesn't appear to be any powershell modules available... or it doesn't seem to know where the modules are? Is there anything else that I can do...
PS C:\Users\Administrator\Downloads> Get-LabAvailableOperatingSystem -Path C:\LabSources
Get-LabAvailableOperatingSystem : The term 'Get-LabAvailableOperatingSystem' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-LabAvailableOperatingSystem -Path C:\LabSources
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-LabAvailableOperatingSystem:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Is there some special way I'm supposed to install msi executables? Ive tried 'start-process' I've tried "Install-Module MSI" I can't seem to get anything to work.
Any suggestions?

Powershell `Set-MpPreference` not recognized

On running Set-MpPreference -DisableScriptScanning 1, I'm getting:
The term 'Set-MpPreference' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Set-MpPreference -DisableScriptScanning 1
~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-MpPreference:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I've gone through the following threads, but nothing seems to work:
Add-MpPreference is not recognized as a name
Powershell Set-MpPreference -DisableRealtimeMonitoring $true not working
I'm using Powershell v5.1 on Windows 7.
What could the reason be?
Have you tried
Import-Module Defender
I am not sure if the module exists on Windows 7 yet tough...
Use 64bit Powershell:
C:\windows\sysnative\WindowsPowershell\v1.0\powershell.exe

Powershell Runbook - The term 'Get-AzureRMWebAppSlot' is not recognized as the name of a cmdlet

I'm trying to switch connection strings of a website to perform DB Failover, as part of HighAvailability. Please suggest if there are any suitable workarounds for the current requirement.
However, the same script which ran on my local machine is not executing while in the Azure portal as a PowerShell Workflow Runbook.
Powershell Code:
Set-AzureRMWebAppSlot -ResourceGroupName $reourceGroupName -Name $WebSiteName -ConnectionStrings $SecnodaryConnectionStrings -Slot $WebSiteSlot
Error:
Set-AzureRMWebAppSlot : The term 'Set-AzureRMWebAppSlot' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At AppService-DBConnnectionFailoverSwitch:37 char:37
+
+ CategoryInfo : ObjectNotFound: (Set-AzureRMWebAppSlot:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
This can be done by adding modules to your automation account under Assets
Assets > Modules > Add a Module
Browse Gallery to find AzureRM.Compute

Pipe more doesn't seem to be working in Powershell v4.0

I'm trying to run a command that displays several screens of text and I'm trying to use the more command, but it doesn't seem to be working.
When I try to use a command like this:
Get-Help Get-Alias -full | more
I get an error that says this:
more.com : The term 'more.com' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:14 char:14
+ $input | more.com
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (more.com:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Anyone have any ideas as to why?
Turns out that powershell.exe was not in the path.