Ubuntu : 'Login-AzureRmAccount' is not recognized as the name of a cmdlet - powershell

I have installed Powershell in my Ubuntu machine. When I enter Login-AzureRmAccount into PowerShell, I get error as below:
PS> Login-AzureRmAccount
Login-AzureRmAccount : The term 'Login-AzureRmAccount' 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
+ Login-AzureRmAccount
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Login-AzureRmAccount:String) [], CommandNotFoundException
When I enter Get-Module -ListAvailable -Name Azure -Refresh, I didn't get any result.
PowerShell version:
powershell -version
powershell v6.0.0-alpha.17
How to solve the above error?

You need to install the Azure PowerShell module first:
#Azure RM NetCore Preview Module Install
powershell Install-Module AzureRM.NetCore.Preview
powershell Import-Module AzureRM.NetCore.Preview
This is my test.
root#shui:/home# powershell
PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
PS /home> Login-AzureRmAccount
VERBOSE: To sign in, use a web browser to open the page https://aka.ms/devicelogin and enter the code F2RKUXRNE to authenticate.
For more information please refer to this link.

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?

'New-SelfSignedCertificate' is not recognised as the name of a cmdlet [duplicate]

On a Windows 7 Professional system, it seems not possible to run New-SelfSignedCertificate. I could on a Windows 10 system.
Yes, the shell was started with "Run As Administrator."
PS C:\> new-selfsignedcertificate
new-selfsignedcertificate : The term 'new-selfsignedcertificate' 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
+ new-selfsignedcertificate
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (new-selfsignedcertificate:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 0 10586 117
As stated in the comments above, this isn't available in Windows 7.
However, if you're looking for something with a similar API and capability, then I have used & can recommend this from Microsoft Script Centre:
https://gallery.technet.microsoft.com/scriptcenter/self-signed-certificate-5920a7c6
Have to install AzureRM module to use azure commands through powershell. You can use below command to do it.
Install-Module -Name AzureRM -AllowClobber

powershell Import psd1 and use command?

I'm trying to run some powershell scripts from a Centos box. I have installed powershell successfully and have then further obtained the scripts i wish to run.
in powershell i have run:
Import-PowershellDataFile ./tools/powershell/DhcpServer.psd1
Then i have tried to use:
Get-DhcpServerv4Scope -ComputerName 10.66.56.66
i have imported the following into my folder /tools/powershell:
DhcpServer.psd1
DhcpServerPSProvider.Format.ps1xml
PS_DhcpServerv4Lease_v1.0.0.cdxml
PS_DhcpServerV4Scope_v1.0.0.cdxml
Ive edited DhcpServer.psd1 to remove all functions other than Get-DhcpServerv4Scope and Get-DhcpServerv4Lease, these are the only two i need for this tool.
heres the output of my attempt:
PS /root/itapp> Import-PowershellDataFile ./tools/powershell/DhcpServer.psd1
Name Value
---- -----
TypesToProcess DhcpServerPsProvider.Types.PS1XML
ClrVersion 4.0
NestedModules {PS_DhcpServerv4Lease_v1.0.0.cdxml, PS_DhcpServerV4Scope_v1.0.0.cdxml}
Author Microsoft Corporation
CompanyName Microsoft Corporation
Copyright © Microsoft Corporation. All rights reserved.
FunctionsToExport {Get-DhcpServerv4Scope, Get-DhcpServerv4Lease}
FormatsToProcess DhcpServerPsProvider.Format.ps1xml
HelpInfoUri http://go.microsoft.com/fwlink/?linkid=285742
GUID 90eaa9df-133a-450c-8728-91055cd946a1
ModuleVersion 2.0.0.0
PowerShellVersion 3.0
PS /root/itapp> Get-DhcpServerv4Scope -ComputerName 10.66.56.66
Get-DhcpServerv4Scope : The term 'Get-DhcpServerv4Scope' 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-DhcpServerv4Scope -ComputerName 10.10.10.10
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-DhcpServerv4Scope:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS /root/itapp>
can anyone help me out?
Thanks
The .psd1 file is the Module Manifest file. There should also be a .psm1 file that contains the code (unless it's a compiled module).
To load the module you need to use:
Import-Module ./tools/powershell/DhcpServer.psd1
The Import-PowershellDataFile just reads the contents of the datafile in to a hashtable, it doesn't load the functions/cmdlets.

Windows sharepoint services (WSS 3.0) stsadm not working

I am new to powershell. I am trying to backup a sharepoint site using a stsadm command but for some reason I keeps on giving me some error.
Here is what I am doing:
PS C:\Users\Administrator> Stsadm –o backup –url >http://server< name:port -filename path\filename to be used for the backup file
Here is the error I am getting:
The term 'stsadm' is not recognized as the name of the cmdlet, function, script file, or operable program. Check the spelling of the name, or path was included, verify that the path is correct and try again,
At line:1 char:7
+ stsadm <<<< stsadm –o backup –url >http://server< name:port -filename path\filename to be used for the backup file
+CategoryInfo : ObjectNotFound: [], CommandNotFoundException
+FullyQualifiedErrorID : CommandNotFoundException
Stsadm is not a powershell script, it is an executable located in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12 or 14 'hive'.
Normally you would refrain from calling stsadm when running powershell as it is effectively deprecated in SharePoint 2010.
You can however change directory to locate the executable and call it if you wish.
Here is a list of stsadm equivalents in powershell.
check this blog post => Backup and Restore SharePoint 2010 Site Collection with PowerShell: http://www.bradleyschacht.com/backup-and-restore-sharepoint-2010-site-collection-with-powershell/
Perhaps, it is what you are looking for

Running VMWare powerCLI commands with SoapUI

I have a powershell script file with PowerCLI commands like Connect-VIServer etc. I am able to run the script file in PowerGUI after I added the library references to VMWare PowerCLI but I don't know how to run it through SoapUI. I'm guessing it won't work with the regular Powershell CLI either. Is there any way to make this work? Here's the error, if it helps:
The term 'Connect-VIServer' is not recognized as the name of a cmdlet, function
, script file, or operable program. Check the spelling of the name, or if a pat
h was included, verify that the path is correct and try again.
At Test.ps1:10 char:23
+ $vm = Connect-VIServer <<<< -Server $vcenterIP -User $vcenterUser -Password
$vcenterPW
+ CategoryInfo : ObjectNotFound: (Connect-VIServer:String) [], Co
mmandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
try calling this in the beginning of the script:
Add-PSSnapin "VMware.VimAutomation.Core" | Out-Null
You cannot execute PowerCLI commands outside of a Powershell host.
To add the snap-in to any Powershell host, use the command Tomas mentioned:
Add-PSSnapin VMware.VimAutomation.Core