Readus Sago
asked on
Attempting to register a remote machine on Team Services
I am attempting to register a remote machine on team services with Powershell. When I enter the script on the remote machine and attempt to run it, I get the error below: Cannot add type. The assembly 'System.IO.Compression.Fil eSystem' could not be found. I have copied the registration script from the Deployment Groups section on team services online.
The server that I am using is windows server 2008 R2. The script is below:
$ErrorActionPreference="St op";If(-NO T ([Security.Principal.Windo wsPrincipa l][Securit y.Principa l.WindowsI dentity]:: GetCurrent ()).IsInRo le([Securi ty.Princip al.Windows BuiltInRol e] “Administrator”)){ throw "Run command in Administrator PowerShell Prompt"};If(-NOT (Test-Path $env:SystemDrive\'vstsagen t')){mkdir $env:SystemDrive\'vstsagen t'}; cd $env:SystemDrive\'vstsagen t'; for($i=1; $i -lt 100; $i++){$destFolder="A"+$i.T oString(); if(-NOT (Test-Path ($destFolder))){mkdir $destFolder;cd $destFolder;break;}}; $agentZip="$PWD\agent.zip" ;(New-Obje ct Net.WebClient).DownloadFil e('https://github.com/Microsoft/vsts-agent/releases/download/v2.116.1/vsts-agent-win7-x64-2.116.1.zip', $agentZip);Add-Type -AssemblyName System.IO.Compression.File System;[Sy stem.IO.Co mpression. ZipFile]:: ExtractToD irectory($ agentZip, "$PWD");.\config.cmd --deploymentgroup --agent $env:COMPUTERNAME --runasservice --work '_work' --url 'https://aaosprojects.visualstudio.com/' --projectname 'xxxxxxxProjects' --deploymentgroupname "xxxxxxxxxDeploymentGroup" ; Remove-Item $agentZip;
The server that I am using is windows server 2008 R2. The script is below:
$ErrorActionPreference="St
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What is the error?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
noticed that my vm was server 2012 not server 2008.
You might want to install WMF5.1 (windows management framework 5.1)
I now get as far as the agent's config
You might want to install WMF5.1 (windows management framework 5.1)
I now get as far as the agent's config
ASKER
Got it working. I also had to upgrade the version of powershell.
It appears that since .NET Framework 4.5+ is required, PS 3.0 or newer is needed because earlier versions of PS used .NET 2.0.
I've seen where you can add some config files to make PS 2.0 use .NET 4.0, but I haven't tried it out.
You can see the version used by looking at the CLRVersion property returned by $PSVersionTable.
I've seen where you can add some config files to make PS 2.0 use .NET 4.0, but I haven't tried it out.
You can see the version used by looking at the CLRVersion property returned by $PSVersionTable.
ASKER