I am following the instructions in here to install the Ops agent on my local Windows machine.
These are the steps that I follow in PowerShell (as admin):
(New-Object Net.WebClient).DownloadFile("https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.ps1", "${env:UserProfile}\add-google-cloud-ops-agent-repo.ps1") Invoke-Expression "${env:UserProfile}\add-google-cloud-ops-agent-repo.ps1 -AlsoInstall"
As soon as I execute this, the output is:
googet : The term 'googet' 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 C:\Users\bot_runner_01\add-google-cloud-ops-agent-repo.ps1:171 char:10
+ if (! (googet listrepos | Select-String -quiet "https://packages.cl ...
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (googet:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
googet : The term 'googet' 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 C:\Users\bot_runner_01\add-google-cloud-ops-agent-repo.ps1:198 char:24
+ if (! $Version -and (googet listrepos | Select-String -quiet "https ...
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (googet:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
googet : The term 'googet' 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 C:\Users\bot_runner_01\add-google-cloud-ops-agent-repo.ps1:205 char:10
+ if (! (googet installed google-cloud-ops-agent 2>&1 | Select-String ...
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (googet:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
No changes made.
How can I fix this? thank you
I had the same issue, found that running the 'Installing the guest environment' scripts in the page below worked for me:
https://cloud.google.com/compute/docs/images/install-guest-environment?authuser=0#installing_guest_environment
I want to build this open source project from source for contributing. I am following this docs for windows. I cloned the repo and install chocolatey as mention. Then I am executing the commands in "prepare the enviorment section" . I was able to run 1st command correctly
PS A:\wasmedgebuild\WasmEdge> choco install cmake ninja vswhere
But when I run second one .
PS A:\wasmedgebuild\WasmEdge> $vsPath = (vswhere -latest -property
installationPath) Import-Module (Join-Path $vsPath
"Common7\Tools\Microsoft.VisualStudio.DevShell.dll") Enter-VsDevShell
-VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0"
I am getting this error:
Join-Path : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:26
+ Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudi ...
+ ~~~~~~~
+ CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
Enter-VsDevShell : The term 'Enter-VsDevShell' 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:3 char:1
+ Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCm ...
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Enter-VsDevShell:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Screenshot
I don't know what is the problem. Am I doing it in wrong way?
I'm using this script to try to upload files to an S3 bucket using cURL.
#S3 parameters
$S3KEY="AKIAYZL7ANTULMU355OD"
$S3SECRET="AKIAYZL7ANTULMU355OD"
$S3BUCKET="quixel-ml-team-data"
$S3STORAGETYPE="STANDARD" #REDUCED_REDUNDANCY or STANDARD etc.
$AWSREGION="us-west-2"
file_path="C:\Users\DELL\AppData\Local\Temp\input_settings.txt"
aws_path="seam-removal\"
bucket="${S3BUCKET}"
date=$(date -R)
acl="x-amz-acl:private"
content_type="application/x-compressed-tar"
storage_type="x-amz-storage-class:${S3STORAGETYPE}"
string="PUT\n\n$content_type\n$date\n$acl\n$storage_type\n/$bucket$aws_path${file_path##/*/}"
signature=$(echo -en "${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64)
curl -s --retry 3 --retry-delay 10 -X PUT -T "$file_path" \
-H "Host: $bucket.${AWSREGION}.amazonaws.com" \
-H "Date: $date" \
-H "Content-Type: $content_type" \
-H "$storage_type" \
-H "$acl" \
-H "Authorization: AWS ${S3KEY}:$signature" \
"https://$bucket.${AWSREGION}.amazonaws.com$aws_path${file_path##/*/}"
However, I'm getting these errors. Any idea about them? Sorry, I'm a novice at this sort of programming.
file_path=C:\Users\DELL\AppData\Local\Temp\input_settings.txt : The term
'file_path=C:\Users\DELL\AppData\Local\Temp\input_settings.txt' 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 C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:11 char:1
+ file_path="C:\Users\DELL\AppData\Local\Temp\input_settings.txt"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (file_path=C:\Us...ut_settings.txt:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
aws_path=seam-removal\ : The term 'aws_path=seam-removal\' 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 C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:12 char:1
+ aws_path="seam-removal\"
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (aws_path=seam-removal\:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
bucket=${S3BUCKET} : The term 'bucket=${S3BUCKET}' 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 C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:13 char:1
+ bucket="${S3BUCKET}"
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (bucket=${S3BUCKET}:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
date=$(date -R) : The term 'date=$(date -R)' 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 C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:14 char:1
+ date=$(date -R)
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (date=$(date -R):String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
acl=x-amz-acl:private : The term 'acl=x-amz-acl:private' 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 C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:15 char:1
+ acl="x-amz-acl:private"
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (acl=x-amz-acl:private:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
content_type=application/x-compressed-tar : The term 'content_type=application/x-compressed-tar' 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 C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:16 char:1
+ content_type="application/x-compressed-tar"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (content_type=ap...-compressed-tar:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
storage_type=x-amz-storage-class:${S3STORAGETYPE} : The term 'storage_type=x-amz-storage-class:${S3STORAGETYPE}' 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 C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:17 char:1
+ storage_type="x-amz-storage-class:${S3STORAGETYPE}"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (storage_type=x-...{S3STORAGETYPE}:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
string=PUT\n\n$content_type\n$date\n$acl\n$storage_type\n/$bucket$aws_path${file_path##/*/} : The module 'string=PUT'
could not be loaded. For more information, run 'Import-Module string=PUT'.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:18 char:1
+ string="PUT\n\n$content_type\n$date\n$acl\n$storage_type\n/$bucket$aw ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (string=PUT\n\n$...file_path##/*/}:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoLoadModule
signature=$(echo -en "${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64) : The term 'signature=$(echo -en
"${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64)' 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 C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:19 char:1
+ signature=$(echo -en "${string}" | openssl sha1 -hmac "${S3SECRET}" - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (signature=$(ech...inary | base64):String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Invoke-WebRequest : Parameter cannot be processed because the parameter name 'T' is ambiguous. Possible matches
include: -TimeoutSec -TransferEncoding.
At C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:20 char:43
+ curl -s --retry 3 --retry-delay 10 -X PUT -T "$file_path" \
+ ~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameter,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
-H : The term '-H' 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 C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:21 char:5
+ -H "Host: $bucket.${AWSREGION}.amazonaws.com" \
+ ~~
+ CategoryInfo : ObjectNotFound: (-H:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-H : The term '-H' 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 C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:22 char:5
+ -H "Date: $date" \
+ ~~
+ CategoryInfo : ObjectNotFound: (-H:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-H : The term '-H' 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 C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:23 char:5
+ -H "Content-Type: $content_type" \
+ ~~
+ CategoryInfo : ObjectNotFound: (-H:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-H : The term '-H' 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 C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:24 char:5
+ -H "$storage_type" \
+ ~~
+ CategoryInfo : ObjectNotFound: (-H:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-H : The term '-H' 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 C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:25 char:5
+ -H "$acl" \
+ ~~
+ CategoryInfo : ObjectNotFound: (-H:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-H : The term '-H' 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 C:\Users\DELL\Desktop\Abdullah Chand\quixel-ml-khalid-chand\script_upload_to_aws_using_curl.ps1:26 char:5
+ -H "Authorization: AWS ${S3KEY}:$signature" \
~~
CategoryInfo : ObjectNotFound: (-H:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
You're mixing a PowerShell with a traditional Unix script.
Further, there's no need to call out the external utilities like OpenSSL and Curl since PowerShell has similar capabilities built in. To sign the URL and perform the Upload without using the AWS SDK, the script would look something like this:
$method = 'PUT'
$service = 's3'
$bucket = "SAMPLES3BUCKETNAME"
$key = 'example-s3-key.txt'
$local_file = "test.txt"
$region = 'us-west-2'
$host1 = $bucket + '.s3-' + $region + '.amazonaws.com'
$access_key = 'SAMPLEACCESSKEY'
$secret_key = 'SAMPLESECRETKEY'
function HmacSHA256($message, $secret)
{
$hmacsha = New-Object System.Security.Cryptography.HMACSHA256
$hmacsha.key = $secret
$signature = $hmacsha.ComputeHash([Text.Encoding]::ASCII.GetBytes($message))
return $signature
}
function getSignatureKey($key, $dateStamp, $regionName, $serviceName)
{
$kSecret = [Text.Encoding]::UTF8.GetBytes(("AWS4" + $key).toCharArray())
$kDate = HmacSHA256 $dateStamp $kSecret;
$kRegion = HmacSHA256 $regionName $kDate;
$kService = HmacSHA256 $serviceName $kRegion;
$kSigning = HmacSHA256 "aws4_request" $kService;
return $kSigning
}
function hash($request)
{
$hasher = [System.Security.Cryptography.SHA256]::Create()
$content = [Text.Encoding]::UTF8.GetBytes($request)
$bytes = $hasher.ComputeHash($content)
return ($bytes|ForEach-Object ToString x2) -join ''
}
$now = [DateTime]::UtcNow
$amz_date = $now.ToString('yyyyMMddTHHmmssZ')
$datestamp = $now.ToString('yyyyMMdd')
$signed_headers = 'host'
$credential_scope = $datestamp + '/' + $region + '/' + $service + '/' + 'aws4_request'
$canonical_querystring = 'X-Amz-Algorithm=AWS4-HMAC-SHA256'
$canonical_querystring += '&X-Amz-Credential=' + [uri]::EscapeDataString(($access_key + '/' + $credential_scope))
$canonical_querystring += '&X-Amz-Date=' + $amz_date
$canonical_querystring += '&X-Amz-Expires=300'
$canonical_querystring += '&X-Amz-SignedHeaders=' + $signed_headers
$canonical_headers = 'host:' + $host1 + "`n"
$canonical_request = $method + "`n"
$canonical_request += "/" + $key + "`n"
$canonical_request += $canonical_querystring + "`n"
$canonical_request += $canonical_headers + "`n"
$canonical_request += $signed_headers + "`n"
$canonical_request += "UNSIGNED-PAYLOAD"
$algorithm = 'AWS4-HMAC-SHA256'
$canonical_request_hash = hash -request $canonical_request
$string_to_sign = $algorithm + "`n"
$string_to_sign += $amz_date + "`n"
$string_to_sign += $credential_scope + "`n"
$string_to_sign += $canonical_request_hash
$signing_key = getSignatureKey $secret_key $datestamp $region $service
$signature = HmacSHA256 -secret $signing_key -message $string_to_sign
$signature = ($signature|ForEach-Object ToString x2) -join ''
$canonical_querystring += '&X-Amz-Signature=' + $signature
$request_url = "http://" + $host1 + "/" + $key + "?" + $canonical_querystring
# Write-Host $request_url
# Using Curl:
# curl.exe '-s', '--retry', '3', '--retry-delay', '10', '-X', 'PUT', '-T', $local_file, $request_url
# Or just put to the URL directly:
Invoke-RestMethod -Uri $request_url -Method Put -InFile $local_file
I want to publish a .NET core application to Elastic Beanstalk and they will be running on Windows Server. I want to make some changes to IIS settings... more precisely Queue Length of Application Pool.
I have aws-windows-deployment-manifest.json file with the following content
{
"manifestVersion": 1,
"deployments": {
"aspNetCoreWeb": [
{
"name": "my-dotnet-core-app",
"scripts": {
"postInstall": {
"file": "SetupScripts/setupAppPool.ps1"
}
}
}
]
}
}
Inside setupAppPool.ps1 script is the following content:
Import-Module WebAdministration
$defaultAppPool = Get-ItemProperty IIS:\AppPools\DefaultAppPool
#$defaultAppPool.PSPath
Write-Host "Display Queue Length before change: " -NoNewline
(Get-ItemProperty IIS:\AppPools\DefaultAppPool\).queueLength
#Value changed here
Set-ItemProperty -Path $defaultAppPool.PSPath -Name queueLength -Value 3000
Write-Host "Display Queue Length after change: " -NoNewline
(Get-ItemProperty IIS:\AppPools\DefaultAppPool\).queueLength
If it will be a simple scritp like hostname it executes with no problem, however this one fails with the following error:
2022-07-12 17:41:25,025 [INFO] Running config InfoTask-TailLogs
AWS.DeploymentCommands.2022.07.12-17.40.30.log:
Starting deployment for my-dotnet-core-app of type AspNetCoreWeb
Parameters:
appBundle: .
iisPath: /
iisWebSite: Default Web Site
Starting restart of my-dotnet-core-app
---------- Executing command "C:\Windows\system32\iisreset.exe /restart" ----------
---------- CWD "" ----------
Attempting stop...
Internet services successfully stopped
Attempting start...
Internet services successfully restarted
---------- Command complete with exit code 0 ----------
Starting ASP.NET Core web deployment my-dotnet-core-app at C:\inetpub\AspNetCoreWebApps\my-dotnet-core-app with IIS path Default Web Site/
Copying C:\staging\. to C:\inetpub\AspNetCoreWebApps\my-dotnet-core-app
Removing existing application from IIS
Adding application to IIS
Commit changes to IIS
---------- Executing command "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy unrestricted -NonInteractive -NoProfile -Command "& { & \"C:\staging\SetupScripts/setupAppPool.ps1\"; exit $LastExitCode }" " ----------
---------- CWD "C:\inetpub\AspNetCoreWebApps\my-dotnet-core-app" ----------
Get-ItemProperty : Cannot retrieve the dynamic parameters for the cmdlet. Retrieving the COM class factory for
component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not
registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At C:\staging\SetupScripts\setupAppPool.ps1:2 char:19
+ $defaultAppPool = Get-ItemProperty IIS:\AppPools\DefaultAppPool
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ItemProperty], ParameterBindingException
+ FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.GetItemPropertyCommand
Get-ItemProperty : Cannot retrieve the dynamic parameters for the cmdlet. Retrieving the COM class factory for
component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not
registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At C:\staging\SetupScripts\setupAppPool.ps1:7 char:2
+ (Get-ItemProperty IIS:\AppPools\DefaultAppPool\).queueLength
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ItemProperty], ParameterBindingException
+ FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.GetItemPropertyCommand
Set-ItemProperty : Cannot bind argument to parameter 'Path' because it is null.
At C:\staging\SetupScripts\setupAppPool.ps1:10 char:24
+ Set-ItemProperty -Path $defaultAppPool.PSPath -Name queueLength -Valu ...
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-ItemProperty], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SetItemProp
ertyCommand
Get-ItemProperty : Cannot retrieve the dynamic parameters for the cmdlet. Retrieving the COM class factory for
component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not
registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At C:\staging\SetupScripts\setupAppPool.ps1:13 char:2
+ (Get-ItemProperty IIS:\AppPools\DefaultAppPool\).queueLength
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ItemProperty], ParameterBindingException
+ FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.GetItemPropertyCommand
Display Queue Length before change: Display Queue Length after change:
---------- Command complete with exit code 0 ----------
Error messages running the command: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy unrestricted -NonInteractive -NoProfile -Command "& { & \"C:\staging\SetupScripts/setupAppPool.ps1\"; exit $LastExitCode }"
Get-ItemProperty : Cannot retrieve the dynamic parameters for the cmdlet. Retrieving the COM class factory for
component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not
registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At C:\staging\SetupScripts\setupAppPool.ps1:2 char:19
+ $defaultAppPool = Get-ItemProperty IIS:\AppPools\DefaultAppPool
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ItemProperty], ParameterBindingException
+ FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.GetItemPropertyCommand
Get-ItemProperty : Cannot retrieve the dynamic parameters for the cmdlet. Retrieving the COM class factory for
component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not
registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At C:\staging\SetupScripts\setupAppPool.ps1:7 char:2
+ (Get-ItemProperty IIS:\AppPools\DefaultAppPool\).queueLength
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ItemProperty], ParameterBindingException
+ FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.GetItemPropertyCommand
Set-ItemProperty : Cannot bind argument to parameter 'Path' because it is null.
At C:\staging\SetupScripts\setupAppPool.ps1:10 char:24
+ Set-ItemProperty -Path $defaultAppPool.PSPath -Name queueLength -Valu ...
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-ItemProperty], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SetItemProp
ertyCommand
Get-ItemProperty : Cannot retrieve the dynamic parameters for the cmdlet. Retrieving the COM class factory for
component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not
registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At C:\staging\SetupScripts\setupAppPool.ps1:13 char:2
+ (Get-ItemProperty IIS:\AppPools\DefaultAppPool\).queueLength
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ItemProperty], ParameterBindingException
+ FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.GetItemPropertyCommand
---------- Executing command "C:\Windows\system32\iisreset.exe /start" ----------
---------- CWD "" ----------
Attempting start...
Internet services successfully started
---------- Command complete with exit code 0 ----------
AWSCommandWrapper.log:
How can I solve this problem?
I'm trying to execute a PowerShell command via system() command, but encounter an exception because of the spaces in the string, I tried a few things but still got the same exception.
Code:
system("powershell.exe -command Invoke-WebRequest http://example.com/myEXE.exe -OutFile C:\\Program Files\\myEXE.exe");
And this is the exception I get:
Invoke-WebRequest : A positional parameter cannot be found that accepts
argument 'Files\myEXE.exe'.
At line:1 char:1
+ Invoke-WebRequest http://example.com/myEXE.exe -OutFile C:\Program File ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
I believe that this should work:
#include <iostream>
#include <bits/stdc++.h>
int main(){
std::cout << "trying system command" << std::endl;
system("powershell.exe -command Invoke-WebRequest https://make.sure.valid.url.to.test.otherwise.will.fail.anyways -OutFile 'C:/Program` Files/myEXE.exe'");
}
The ` charachter should allow you to properly escape the space.