Hi Guys, I'm trying to modify this PowerShell script and put it in windows startup. So every restart a VBScript will call this PowerShell script and it will update the info like a Windows Sysinternals BGinfo.
https://pastebin.com/nDh2L9dm
# Close Graphics
$image.Dispose();
# Save and close Bitmap
$background.Save($out, [system.drawing.imaging.imageformat]::Png);
$background.Dispose();
$bmp.Dispose();
# Output file
Get-Item -Path $out
This is the error I get in PowerShell ISE
Exception calling "Save" with "2" argument(s): "A generic error occurred in GDI+."
At D:\Desktop\PS-BGInfo-My-Version.ps1:195 char:5
+ $background.Save($out, [system.drawing.imaging.imageformat]::Png) ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ExternalException
Related
We have a powershell script which is used to call an API by establishing connection over SSL. The certificates are placed along powershell script to be used by it. And the password is mentioned in an ini file which script reads. It was working fine earlier but suddenly it has started giving below error:
Exception calling "Import" with "3" argument(s): "The specified network password is not correct.
"
At C:\Users\Administrator\Desktop\NewInstallIssue\Download\win\installCDWindows.ps1:70 char:3
+ $cert.Import($CertificatePath, $KeyStore_Password ,'DefaultKeySet')
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CryptographicException
The part of powershell script throwing this error is:
$cert= New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$CertificatePath = Join-Path -Path $PSScriptRoot -ChildPath 'cdCert.pfx'
$cert.Import($CertificatePath, $KeyStore_Password ,'DefaultKeySet')
$KeyStore_Password contains correct password as I tested what is stored in this variable just before $cert.Import using echo.
I am creating a script using PowerShell to make a http request to an endpoint. I know starting from PowerShell version 3, I can use Invoke-RestMethod or Invoke-WebRequest, but the script is required to be compatible with PowerShell version 2.
As I have googled and read many forums, the most common solution is to use the .Net class System.Net.WebRequest. I am executing the below lines:
$Uri = "https://url"
$Web = [System.Net.WebRequest]::Create($Uri)
And I am facing below error:
Create : Exception calling "Create" with "1" argument(s): "Configuration system failed to initialize"
At line:1 char:32
+ [System.Net.WebRequest]::Create <<<< ($Uri)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Can you please help what might caused this problem?
I have installed Azure stack development kit and i am trying to install the App service.
Then when i have to run the PS1 script Create-AADIdentityApp.ps1 i fill in the following parameters
DirectoryTenantName
AdminArmEndpoint
TenantArmEndpoint
CertificateFilePath
Then i get the following error
New-Object : Exception calling ".ctor" with "3" argument(s): "The system cannot find the file specified.
"
At C:\app-service-certificate-install\Create-AADIdentityApp.ps1:81 char:24
+ ... rtificate = New-Object System.Security.Cryptography.X509Certificates. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
does anyone have any experience?
You provided a invalid CertificateFilePath.
It should be Full path to the identity application certificate file generated earlier.
Please check and correct it.
Following the steps to install Chocolatey via Powershell doesn't work on my Windows 7 64bit PC. I'm following https://chocolatey.org/install#install-from-powershell-v3
I have confirmed the ExecutionPolicy and that system path has
Powershell;
PS C:\Users\a> Get-ExecutionPolicy
AllSigned
PS C:\Users\a> ($env:Path).split(';')
%SystemRoot%\system32\WindowsPowerShell\v1.0\
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
C:\Program Files (x86)\Intel\iCLS Client\
C:\Program Files\Intel\iCLS Client\
C:\ProgramData\Oracle\Java\javapath
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Program Files\Java\jre1.8.0_40\bin
C:\Program Files\Java\jdk1.8.0_40\bin
C:\Program Files (x86)\AMD\ATI.ACE\Core-Static
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Program Files\Intel\Intel(R) Management Engine Components\DAL
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL
C:\Program Files\Intel\Intel(R) Management Engine Components\IPT
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT
C:\HashiCorp\Vagrant\bin
C:\Program Files (x86)\Git\bin
C:\Program Files (x86)\Skype\Phone\
C:\Program Files (x86)\Git\bin
C:\Program Files (x86)\Git\libexec\git-core
C:\Program Files (x86)\Nmap
C:\Program Files\smartmontools\bin
Here are my error messages;
PS C:\Users\a> iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
???# : The term '???#' 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
+ ???# =====================================================================
+ ~~~~
+ CategoryInfo : ObjectNotFound: (???#:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.5.
!Test-Path : The term '!Test-Path' 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:188 char:11
+ } elseif (!Test-Path $7zaExe) {
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (!Test-Path:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Extracting C:\Users\a\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\a\AppData\Local\Temp\chocolatey\chocInstall...
Exception calling "Start" with "0" argument(s): "The system cannot find the file specified"
At line:211 char:3
+ $process.Start() | Out-Null
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : Win32Exception
Exception calling "BeginOutputReadLine" with "0" argument(s): "StandardOut has not been redirected or the process hasn't started yet."
At line:212 char:3
+ $process.BeginOutputReadLine()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
Exception calling "WaitForExit" with "0" argument(s): "No process is associated with this object."
At line:213 char:3
+ $process.WaitForExit()
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompression = 'true' and call install again. Error: 7-Zip signalled an unknown error (code )
At line:225 char:15
+ default { throw "$errorMessage 7-Zip signalled an unknown error (code $exitC ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Unable to unzip...n error (code ):String) [], RuntimeException
+ FullyQualifiedErrorId : Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompression = 'true' and call install again. Error: 7-Zip signalled an unknown error (code )
I have tried the error messages suggestion on the last line
Perhaps try setting $env:chocolateyUseWindowsCompression = 'true'
But that only results in a whole series of other errors
PS C:\admin\scripts> iwr https://chocolatey.org/install.ps1 -UseBasicParsing
StatusCode : 200
StatusDescription : OK
Content : # =====================================================================
...
You're downloading a UTF-8-encoded file (the content begins with the characteristic UTF-8 byte order mark ), but it's being treated as ASCII text.
Besides:
I'm following https://chocolatey.org/install#install-from-powershell-v3.
No, you're not. The website you referenced tells you to use
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
which works as advertised, whereas you're trying to use
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
If you want to use that approach you need to remove the BOM from the content before piping it into Invoke-Expression:
(iwr https://chocolatey.org/install.ps1 -UseBasicParsing).Content -replace '^' | iex
I'm trying to configure windows update with the Microsoft.Update.AutoUpdate COM object with Powershell v4, on a Windows 2008 r2. I'm however running into a little trouble. When trying to set the NotificationLevel, I'm getting the following error (Note running with elevated permissions).
$WUSettings = (New-Object -com "Microsoft.Update.AutoUpdate").Settings
$WUSettings.NotificationLevel=4
$WUSettings.save()
Output:
Exception setting "NotificationLevel": "Exception from HRESULT:
0x80240037" At line:1 char:1
+ $WUSettings.NotificationLevel=4
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
+ FullyQualifiedErrorId : CatchFromBaseAdapterSetValueTI
Any help greatly appreciated!