Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDP script does not work - ObjectNotFound: (Get-NetIPAddress:String) when executing enable-rdp.ps1 #3691

Closed
GitMensch opened this issue Jul 7, 2021 · 10 comments · Fixed by #3692

Comments

@GitMensch
Copy link
Contributor

per https://www.appveyor.com/docs/how-to/rdp-to-build-worker/ I've added

 $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

To my build config for failures, it is actually downloaded and executed (as it was before) but now fails to execute:

$blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
iex : The term 'Get-NetIPAddress' 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\appveyor\AppData\Local\Temp\1\1fn9k92dyi.ps1:6 char:20
+ ... dp = $true; iex ((new-object net.webclient).DownloadString('https://r ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Get-NetIPAddress:String) [Invoke-Expression], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.InvokeExpressionCommand
 
Command exited with code 1

So either the documentation needs an update or the script... or both.

@FeodorFitsner
Copy link
Member

I wasn't able to reproduce the issue on Visual Studio 2019 and Visual Studio 2017 images. Here is some of the tests: https://ci.appveyor.com/project/FeodorFitsner/simple-console/builds/39903719

There could be some changes into PowerShell environment during the build. Could you, perhaps, do a simple repro in a public repository?

@GitMensch
Copy link
Contributor Author

Just rechecked, that was running on PS Core, possibly this is the reason?

@FeodorFitsner
Copy link
Member

I've checked with PS Core and it worked as well. Did it work for you with Windows PowerShell?

@GitMensch
Copy link
Contributor Author

To tests that I've used a working environment and added the following in appveyor.yml:

on_success:
- pwsh: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

Result in all environments of that build with

image:
- Visual Studio 2015
- Visual Studio 2017

Is the message above, it does work in the VS2019 image (while it previously also worked in the older ones).

What do we do with this information now?

@FeodorFitsner
Copy link
Member

Try using ps instead of pwsh for RDP script.

@GitMensch
Copy link
Contributor Author

OK, ps is "Powershell" and pwsh is "Powershell Core". The script works with both in the VS2019 image but for the others only in "Powershell".

So I assume that the cmdlet Get-NetIPAddress was added later and the two "older" images have an older version of ps-core that does not support this.

Options:

  • Ideally: there is an alternative cmdlet that can be used in both older and new ps scripts (good for portability)
  • Otherwise the docs and file may should explicit say that this only works with recent ps-core, older environments may always need to use ps.

What do you think?

@FeodorFitsner
Copy link
Member

Actually, all examples in RDP KB use ps prefix. Indeed, VS 2015 and VS 2017 images have outdated PS Core, so use ps which guaranteed has that cmdlet.

@GitMensch
Copy link
Contributor Author

Hm, would the default workers used for public repos work with $nonat set? In this case #3692 would solve it.

@FeodorFitsner
Copy link
Member

$nonat is never set by build workers (I'm not even sure why that variable was introduced at all, maybe for BYOC scenarios), so that fix won't help to the fact that pre 7.x PS Core does not have Get-NetIPAddress cmdlet.

@GitMensch
Copy link
Contributor Author

GitMensch commented Jul 12, 2021 via email

FeodorFitsner pushed a commit that referenced this issue Aug 23, 2021
* remove IP lookup for nonat

possibly fixing #3691

* Update enable-rdp.ps1

fixing #3691
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants