Link to home
Start Free TrialLog in
Avatar of Readus Sago
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.FileSystem' 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="Stop";If(-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] “Administrator”)){ throw "Run command in Administrator PowerShell Prompt"};If(-NOT (Test-Path $env:SystemDrive\'vstsagent')){mkdir $env:SystemDrive\'vstsagent'}; cd $env:SystemDrive\'vstsagent'; for($i=1; $i -lt 100; $i++){$destFolder="A"+$i.ToString();if(-NOT (Test-Path ($destFolder))){mkdir $destFolder;cd $destFolder;break;}}; $agentZip="$PWD\agent.zip";(New-Object Net.WebClient).DownloadFile('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.FileSystem;[System.IO.Compression.ZipFile]::ExtractToDirectory($agentZip, "$PWD");.\config.cmd --deploymentgroup --agent $env:COMPUTERNAME --runasservice --work '_work' --url 'https://aaosprojects.visualstudio.com/' --projectname 'xxxxxxxProjects' --deploymentgroupname "xxxxxxxxxDeploymentGroup" ; Remove-Item $agentZip;
SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Readus Sago
Readus Sago

ASKER

I have .net 4.5 installed on this server and still not working. I get an error when running this statement Add-Type -AssemblyName System.IO.Compression.FileSystem
What is the error?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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.