I am trying to set up my AWS on my local machine through windows PowerShell, it gives me the following error message;
PS C:\> Set-AWSCredentials -AccessKey {AAAAAAAAAAAAAAA} -SecretKey {AAAAAAAAAAAAA} -Stor
eAs {default}
Set-AWSCredentials : Cannot evaluate parameter 'AccessKey' because its argument is specified as a script block and
there is no input. A script block cannot be evaluated without input.
At line:1 char:31
+ Set-AWSCredentials -AccessKey {AAAAAAAAAAAAAAA} -SecretKey {AAAAAAAAAAAA ...
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : MetadataError: (:) [Set-AWSCredentials], ParameterBindingException
+ FullyQualifiedErrorId : ScriptBlockArgumentNoInput,Amazon.PowerShell.Common.SetCredentialsCmdlet
And my Powershell Version is following;
Major Minor Build Revision
----- ----- ----- --------
3 0 -1 -1
Anyone knows what the problem is?
Thanks
It looks like you need to drop the brackets from your code, the documentation from amazon that comes up first in google includes them for some reason but if you check out http://docs.aws.amazon.com/powershell/latest/reference/items/Set-AWSCredentials.html and the examples near the bottom you'll see that the function is really expecting them in a string just like any other powershell cmdlet.
Set-AWSCredentials -AccessKey AAAAAAAAAAAAAAA -SecretKey AAAAAAAAAAAAA -StoreAs default
Should do the trick for you (if there are spaces in anything make sure to wrap the string in quotes)
Related
I have win10 Pro and Powershell 5.1
On the other hand VSC(1.54.1) with the powershell extention (ms-vscode-powershell, v2021.2.2).
The command
$day = $day.ToLower()
on the Powershell prompt works fine
But in VSC it says:
+ $dayName = $dayName.ToLower()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
MethodNotFound???
Any help?
Thanks
$dayName.ToString().ToLower() should do what you expect here (according to your comment).
.ToLower() is a string method and you are trying to use it on System.DayOfWeek, which doesn't have that method.
In order to keep track of your variables and just what they are, running $myVariable.GetType().FullName can be very handy - I use it all the time.
In your example, running
$day.GetType().FullName
$dayName.GetType().FullName
would probably result in something like
PS C:\> $day.GetType().FullName
System.String
PS C:\> $dayName.GetType().FullName
System.DayOfWeek
I'm trying to format the output of this command to get only the dfsnamespace only like that :
\\F-TYPHON\DATA13\AI-Project
I can not use the Get-DfsnFolderTarget cmdlet because the RSAT-DFS-Mgmt-Con
is not installed on all servers and I cannot install it .
$DFSPath="\\F-TYPHON\shared\AI-Project"
PS C:\> dfsutil client property state $DFSPath
Active, Online \\F-TYPHON\DATA13\AI-Project
Done processing this command.
I've tried this .
PS C:\> $dfs=dfsutil client property state $DFSPath
PS C:\> $dfs.trimstart("Active, Online")
Method invocation failed because [System.Object[]] doesn't contain a method named 'trimstart'.
At line:1 char:15
+ $dfs.trimstart <<<< ("Active, Online")
+ CategoryInfo : InvalidOperation: (trimstart:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
any help will be apreciated I can list all volume data for the filer but there's many incoherence in the structure so I need only to list the shared folder under "shared" on a filer and then procces it with dfsutil to get the absolut path
Use a regular expression to match the text output of dfsutil:
$DFSPath="\\F-TYPHON\shared\AI-Project"
if ((dfsutil client property state $DFSPath) -match "(?<=\s{2,})\\\\.*"){
$DFSNameSpace = $Matches.Value
}
here (?<=\s{2,})\\\\.* matches two or more whitespace \s in a lookbehind
followed by two (escaped) backslashes and the remainder of the line.
thank you for your help
i've found a solution that i can use in a way it's not 100% powershell but i can use it to extract the output in a format that i can use it in a loop and than make automated robocopylines with powershell
here the code for the output that i found
$DFSPath="\F-TYPHON\shared\AI-Project"
$dfspath=(dfsutil client property state $DFSPath |findstr /i \F-TYPHON)|out-string
$dfs=$dfspath.Trimstart("Active, Online ")
write-host $dfs
the output is
\F-TYPHON\DATA13\AI-Project
it's certainly not the best but i can work with it
if you have any others suggestion you're welcome
I have been tasked with creating a number of active directory groups using PowerShell. The problem is all the group names contain double colons "::" (the naming standard was created long before I joined!).
When running the following command:
NEW-ADGroup –name "XX123::Test_Group_Creation" –groupscope Global –path "OU=TestOU,DC=TestDomain,DC=local"
The following error is received:
NEW-ADGroup : The name provided is not a properly formed account name
At line:1 char:1
+ NEW-ADGroup –name "XX123::Test_Group_Creation" –groupscope Global –path "OU=Test ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (CN=XX123::Test_...Domain,DC=local:String) [New-ADGroup], ADException
+ FullyQualifiedErrorId : The server is unwilling to process the request,Microsoft.ActiveDirectory.Management.Commands.NewADGroup
If you create the group manually (in the gui) you get the following warning but you are still able to create it:
How can I get around this issue. F.Y.I. I have tried to escape the colons with a back tick and also a forward slash, none of which have worked
The : character is not valid for the sAMAccountName attribute, so you need to replace : with another character (the GUI uses _) when creating the group. You can use the -replace operator to do this pretty easily in PowerShell.
I have 4 Exchange 2013 servers on 2012R2.
3 servers are updated to CU11, last one is running CU10.
After the update to CU11 there are some piped commands I can't run on the servers that are updated to CU11, like this one:
Get-TransportService | Get-MessageTrackingLog -Recipients mail#mail.com
The error I get is this:
The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
+ CategoryInfo : InvalidArgument: (Exchangerservername:PSObject) [Get-MessageTrackingLog], ParameterBindingException
+ FullyQualifiedErrorId : InputObjectNotBound,Get-MessageTrackingLog
+ PSComputerName : xxxxxx
I have tried to write the command not copy.
Also tried to Set-ExecutionPolicy Unrestricted.
Powershell version is the same on all servers.
Easiest way around this is to use a foreach:
get-transportservice | foreach {get-messagetrackinglog -resultsize unlimited `
-start 05/21/2016 -recipient user#email.com}
I don't know if this is your issue but there are known Exchange Management Shell issues with CU11. https://jaapwesselius.com/2016/01/19/exchange-2013-cumulative-update-11-install-it-or-not/ Here is a link.
Trying to automate ftp site manipulation on IIS7.5, through powershell, but I can't start the ftp site. Everything else, so far, I succeeded.
PS IIS:\Sites> Get-ChildItem | Where {$_.Name -eq "FtpData"}
Name ID State Physical Path Bindings
---- -- ----- ------------- --------
FtpData 3 Stopped D:\Services\_Empty ftp *:80:
PS IIS:\Sites> Start-WebSite -Name "FtpData"
Start-WebSite : The object identifier does not represent a valid object. (Exception from HRESULT: 0x800710D8)
At line:1 char:1
+ Start-WebSite -Name "FtpData"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Website], COMException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.IIs.PowerShell.Provider.StartWebsiteCommand
This issue is address in technet "Starting / Stoping an FTP site using PowerShell... IIS 7.5 on 2008R2" but is has three years old.
Using the appcmd has the same issue:
C:\Users\myself>c:\Windows\system32\inetsrv\appcmd start site FtpData
ERROR ( hresult:800710d8, message:Command execution failed.
The object identifier does not represent a valid object.
)
This article FTP on IIS 7 on Server Core indicates to start it from the UI Console, but that means it can't be automated.
Has any one got a solution to this?
Stumbled upon this through Powershell autocomplete and turned out working on Server 2012 R2:
$ftpSite = IIS:\Sites\FtpData
$ftpSite.ftpServer.Start()
The $ftpSite... did not work for me. I also found the below to be neater.
To Start:
(get-Website -Name "myftpsite").ftpserver.start()
To Stop:
(get-Website -Name "myftpsite").ftpserver.stop()
Source: https://peter.hahndorf.eu/blog/iisftp.html
(Forever Breathes The Lonely Word - Peter Hahndorf on software
IIS - Managing FTP sites with PowerShell)