Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
Installation on windows should be very simple from the docs https://kubernetes.io/docs/tasks/tools/install-kubectl but mine fails at second step
Install-Script -Name 'install-kubectl' -Scope CurrentUser -Force
install-kubectl.ps1 [-DownloadLocation <path>]
install-kubectl.ps1 c:\kubectl
==>Getting download link from https://kubernetes.io/docs/tasks/tools/install-kubectl/
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
At C:\Program Files\PowerShell\Scripts\install-kubectl.ps1:31 char:8
+ $req = Invoke-WebRequest -UseBasicParsing -Uri $uri
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
It seems like it is trying to download something from https://kubernetes.io/docs/tasks/tools/install-kubectl/ but it can not.
I succeeded to check that connection, I do have access to internet from that Windows Server:
PS C:\Users\e561> Test-NetConnection -ComputerName "kubernetes.io" -Port 443
ComputerName : kubernetes.io
RemoteAddress : 147.75.40.148
RemotePort : 443
InterfaceAlias : Ethernet 2
SourceAddress : 10.7.147.211
TcpTestSucceeded : True
As mentioned in the comments :
You can download kubectl.exe from here - and later add the path kubectl.exe located to environment variables.
Related
Environment
Home VMware lab consisting of a single VMware ESXi host.
Client version: 1.33.4
Client build number: 14093553
ESXi version: 6.7.0
ESXi build number: 14320388
PC running the script
Windows 10
Powershell 5.1
VMware PowerCLI 12.0.0 build 15947286
user connecting has the vmware administrator role attached to it.
Code
clear-host
$vc = 'my-hhost-ip'
$user='myuser'
$pw='mypassword'
Set-PowerCLIConfiguration -InvalidCertificateAction:ignore
Connect-VIServer -server $vc -Protocol https -user $user -password $pw
Error
Connect-VIServer : Specified method is not supported.
At line:6 char:1
+ Connect-VIServer -server $vc -Protocol https -user $user -password $p ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotImplemented: (:) [Connect-VIServer], PSNotSupportedException
+ FullyQualifiedErrorId : NotSupported,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer
PSMessageDetails :
Exception : System.Management.Automation.PSNotSupportedException: Specified method is not supported.
TargetObject :
CategoryInfo : NotImplemented: (:) [Connect-VIServer], PSNotSupportedException
FullyQualifiedErrorId : NotSupported,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 16
PipelineIterationInfo : {}
What I've tried
leaving of the credentials and having it ask, gives the same error
Deliberately getting the password wrong - gives an incorrect password message
Removing the administrator role from the user - gives a not authorised message
The output of the last two tests leads me to believe I am in fact authenticating ok, but that there is then some setting/service I've not set or enabled that allows it to connect after authenticating.
Any suggestions would be appreciated.
ESXi hosts assigned the free license don't grant access to consume the API services, which is what PowerCLI is doing under the covers.
The error message is confirming that you do not have the ability to access the API services.
Just to add a secondary answer in case anybody else stumbles upon it.
I thought at first that it was because I was connecting to my home eval edition.
However, I got the exact same issue when connecting to our corporate environment.
It turns out that my account on the machine was locked down to PowerShell constrained language mode. Running the commands on an account that did not have the mode set allowed them to run ok.
To add a further answer to this in case it helps anyone, in my case I just needed to run PowerShell as administrator.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I ran cmd as administrator and input:
start powershell
when open the powershell, I input:
$client = new-object System.Net.WebClient
$client.DownloadFile("https://www.cse.ust.hk/msbd5003/data/fruits.txt","D:\IT\fruits.txt")
here is the error information:
Exception calling "DownloadFile" with "2" argument(s): "The underlying connection was closed: An unexpected error occurred on a send."
At line:1 char:1
+ $client.DownloadFile("https://www.cse.ust.hk/msbd5003/data/fruits.txt ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
I tried adding $ client.Credentials = Get-Credential while it did not work.
My guess would be that since you're connecting through https you may need to set a more secure schannel protocol to communicate with the site you're trying to download from.
add this line indicating security protocol before your webclient request
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$client = new-object System.Net.WebClient
$client.DownloadFile("https://www.cse.ust.hk/msbd5003/data/fruits.txt","D:\IT\fruits.txt")
Alternately, if you are only running this script from one machine, you can set .NET to use secure protocols by default.
You can read more about it at https://learn.microsoft.com/en-us/dotnet/framework/network-programming/tls
Key - HKEY_LOCAL_MACHINE\SOFTWARE\[Wow6432Node\]Microsoft\.NETFramework\<VERSION>
Name - SchUseStrongCrypto
Value - 1
Also, the native PowerShell cmdlet invoke-webrequest may simplify your request.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri "https://www.cse.ust.hk/msbd5003/data/fruits.txt" -OutFile "D:\IT\fruits.txt"
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I created a Windows VM on Windows Azure with winrm over SSL set.
But, I can't connect it using a powershell script.
When I'm running the following:
Enter-PSSession -ConnectionUri https://myniceapp.cloudapp.net:5986
-Credential "hostname/username"
-SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck)
I'm getting a prompt asking for password and after I type it I manage to connect.
But, when I try to automate it, it always returns with "Access is denied"
$securePassword = ConvertTo-SecureString -AsPlainText -Force "password"
$cred = New-Object System.Management.Automation.PSCredential "hostname/username", $securePassword
Enter-PSSession -ConnectionUri https://myniceapp.cloudapp.net:5986 -Credential $mycreds -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck)
Any ideas?
Edit
The full error looks like this:
Enter-PSSession : Connecting to remote server myniceaspp.cloudapp.net failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ Enter-PSSession -ConnectionUri https://myniceaspp.cloudapp ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (https:// myniceaspp...udapp.net:5986/:Uri) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
Had similar problems recently. Would suggest you carefully check if the user you're connecting with has proper authorizations on the remote machine.
You can review permissions using the following command.
Set-PSSessionConfiguration -ShowSecurityDescriptorUI -Name Microsoft.PowerShell
Found this tip here:
http://blogs.technet.com/b/heyscriptingguy/archive/2010/11/17/configure-remote-security-settings-for-windows-powershell.aspx
It fixed it for me.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
PS C:\WINDOWS\system32> Push-Location
PS C:\WINDOWS\system32> Set-Location C:\
PS C:\> Set-Location HKLM:\Software\Wow6432Node\Microsoft\jet\4.0\Engines\Excel
PS HKLM:\Software\Wow6432Node\Microsoft\jet\4.0\Engines\Excel> Set-ItemProperty . TypeGuessRows "0"
PS HKLM:\Software\Wow6432Node\Microsoft\jet\4.0\Engines\Excel>
Above is my code.It works manually. But how to run the above script on server.
When save my script in myscript.ps1 and try to execute getting below error
PS C:\> .\myscript.ps1
Get-Process : A positional parameter cannot be found that accepts argument 'Push-Location'.
At C:\myscript.ps1:1 char:3
+ PS <<<< C:\WINDOWS\system32> Push-Location
+ CategoryInfo : InvalidArgument: (:) [Get-Process], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetProcessCommand
Push-Location
Set-Location C:\
Set-Location HKLM:\Software\Wow6432Node\Microsoft\jet\4.0\Engines\Excel
Set-ItemProperty . TypeGuessRows "0"
It works with the above code...Robert thanks for your help...
Our server had been set up to have Powershell Remoting enabled, so that we can remotely execute scripts from our developer machines. I should add that I am not massively fluent in Powershell and was not involved in setting this up.
However recently our server suffered a fault and subsequently had to be restored. The restoration process was supposed to restore Windows back to its last backed up state including all programs and data. However since the restore, Powershell Remoting no longer works on the server.
I receive the following error now when running Enter-PSSession ServerName.
Enter-PSSession : Connecting to remote server failed with the following error message : <f:WSManFault xmlns:f="http://s
chemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2147749890" Machine="ServerName"><f:Message></f:Message></f:WSManFaul
t> For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:16
+ enter-pssession <<<< ServerName
+ CategoryInfo : InvalidArgument: (ServerName:String) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
Or I get the following error when running New-PSSession ServerName
[ServerName] Connecting to remote server failed with the following error message : <f:WSManFault xmlns:f="http://schemas.
microsoft.com/wbem/wsman/1/wsmanfault" Code="2147749890" Machine="ServerName"><f:Message></f:Message></f:WSManFault> For
more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportExc
eption
+ FullyQualifiedErrorId : PSSessionOpenFailed
(I have replaced the actual server name above with ServerName for privacy purposes)
Any help is much appreciated
Based on this Microsoft Connect item, try adding-SessionOption (New-PSSessionOption -NoMachineProfile) to your Enter-PSSession command.
I have no idea why this would be needed, but it's worth a shot.