ObjectNotFound Error while using cmdlet to access AWS IAM - powershell

I am trying to generate AWS API gateway access key through powershell. However, everytime I try to use any cmdlet it throws an error:
For example:
Get-AWSCredential -ListProfileDetail
will result in an error like this:
Get-AWSCredential : The term 'Get-AWSCredential' 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-AWSCredential -ListProfileDetail
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-AWSCredential:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
When I display the list of commands through Get-Command the AWS cmdlets do not pop up.
Any idea what could be the problem?

Long story short, run this: Install-Package -Name AWSPowerShell
You may need to run PS as an Administrator for the Install-Package command to work. Additionally, you may be prompted to install 'nuget', answer yes. If you receive the security warning about PSGallery, answer yes.
Here is Amazon's docs on PS cmdlets: http://docs.aws.amazon.com/powershell/latest/userguide/pstools-getting-set-up.html

Related

PowerShell The term 'which' is not recognized as cmdlet function script file or operable program

I am using PowerShell and want to do a which command, however I am seeing this error:
which : The term 'which' 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
+ which xxxxxx
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (which:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I have done a search on Google and there is no specific answer to my question. Has anyone encountered the same error before and how can I fix it?
Putting an answer together from the comments:
which is a standard command of Linux, but is not normally present on Windows.
The equivalent command is Get-Command, or if you have it, you can run where.exe.

No PowerShell help in Docker using WindowServerCore

I'm using Docker and WindowsServerCore base image to serve different PowerShell modules to some Ops. If I start the container and try to use the Get-Help cmdlet I get the following error:
PS C:\Users\ContainerAdministrator> help *service*
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:9 char:19
+ } else { $input | more.com }
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (more.com:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Any hints?
Thx
From these two questions 1 and 2 state that help doesn't run as Get-Help as many commands do when run without Get- but is a function that pipes to more.com. Likely the executable more.com isn't included in the WindowsServerCore base image.

Not able to execute AWS Powershell tool cmdlet in TFS Post build script

I am trying to execute the few aws cmdlet command in post build script with TFS build. I have a AWS SDK tool is installed in build controller. I am able to run the same commands manually in Build controller. But when i invoke those commands in TFS post build script. It's giving me error that its not able to find the cmdlet installed on the build controller. I tried to change the execution policy but didn't help. I have an execution policy - bypass right now. script is executing but only the commands is not able to execute. I am thinking that it's issue because of something like Execution policy. Do we need to check anything else same like execution policy while we invoke any third party cmdlet from power shell.
Commands:
Set-AWSCredentials -AccessKey -SecretKey
Set-DefaultAWSRegion -Region us-east-1
Write-S3Object -BucketName agero-source-package -File "\\b tfadfa\adfa\adf\asdf\adsf\asdf\asd\xyz.zip"
Error:
Set-DefaultAWSRegion : The term 'Set-DefaultAWSRegion' 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 \\b-tfsbc001wv\c$\MV\BuildETA-API.ps1:41 char:26
+ cd "\\b-tfsbc001wv\C$" | Set-DefaultAWSRegion -Region us-east-1
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-DefaultAWSRegion:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Write-S3Object : The term 'Write-S3Object' 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 \\b-tfsbc001wv\c$\MV\BuildETA-API.ps1:43 char:26
+ cd "\\b-tfsbc001wv\c$" | Write-S3Object -BucketName agero-source-package -File " ...
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Write-S3Object:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
From the error messages, it would appear that the AWSPowerShell module cannot be found/automatically loaded by whatever account the TFS build process is running as.
Check that the module is installed to a globally available location under which the version of PowerShell you have searches for modules or, that the path to the module folder is present in the $PSModulePath environment variable for the TFS build account.
I got the same error on my TFS Build Agent:
Set-DefaultAWSRegion : The term 'Set-DefaultAWSRegion' 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.
After I installed AWS Command Line Interface x64 bit (AWSCLI64) I was able to set the Set-DefaultAWSRegion by stepping over the line of code.
I was getting this error until I ran Powershell using "Run as Administrator." So the problem might be with permissions.

How to reserve a static IP for Azure Virtual Machines?

Amazon have Elastic IP that you can assign to an instance,
How can I do that with Azure for existing VM?
(I don't want to change all my DNS entries if the IP changes)
I found some articles about running power shell commands
1. http://michaelwasham.com/windows-azure-powershell-reference-guide/using-reserved-ip-addresses-with-microsoft-azure-virtual-machines/
2. http://azure.microsoft.com/blog/2014/05/14/reserved-ip-addresses/
3. http://azure.microsoft.com/blog/2014/04/22/static-internal-ip-address-for-virtual-machines/
But the commands are not recognized on my server (Windows server 2012 R2)
Any idea how can I do that?
This is the error that I'm getting on Power Shell:
PS C:\> New-AzureReservedIP – ReservedIPName "137.117.11.18" –Label "people-dns-ip" –Location "US West"
New-AzureReservedIP : The term 'New-AzureReservedIP' 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-AzureReservedIP – ReservedIPName "137.117.11.18" –Label "people-dns-ip" –Loc ...
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (New-AzureReservedIP:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Sounds like you are missing the requiered CMD for PowerShell. Please download the Microsoft Webinstaller:
Download Microsoft Web-Installer
and do an fresh installation of Microsoft PowerShell. After this you should be able to use the "New-AzureReservedIP" command. Maybe you are running an old version of PowerShell without this CMDlet.
For more information about installation PowerShell, see: Configure and Install PowerShell (Azure)

The term 'get-splogevent' is not recognized as the name of a cmdlet

I'm new to Sharepoint... and I'm trying to deploy a simple web part.
When I do deploy it and place it on a page, I get an error with a correlation id.
Now, I'm trying to get details about the error, and using Powershell I type...
get-splogevent | ?{$_Correlation -eq "bcce1b39-f277-4b2b-b8f8-4c113a30f193" }
But it's giving me an error....
The term 'get-splogevent' 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:15
+ get-splogevent <<<< | ?{$_Correlation -eq "bcce1b39-f277-4b2b-b8f8-4c113a30f193" }
+ CategoryInfo : ObjectNotFound: (get-splogevent:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Any ideas as to what I'm doing wrong?
Most likely you are on an ordinary Powershell session. The Sharepoint management snap-in is not being loaded, so cmdlet is not found. Take a look at an article that describes how to load the snap-in automatically to all Powershell sessions.
The snap-in is loaded manually like so,
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
I was starting the solo powershell instead of the sharepoint one. In the task bat there is "Sharepoint 2010 Management Shell", using that worked.