Automate Remote Machine Logins, Export Windows Roles & Features – PowerShell Scripts

By April 8, 2020 August 7th, 2020 No Comments

Automate Remote Machine Logins, Export Windows Roles & Features – PowerShell Scripts

Automate Remote Machine login

When developers are working on several remote machines via their local user machine, frequent and regular logins to the virtual machines (VMs) are tedious and time-consuming. Fortunately, DevOps automation has made things lot easier for software developers and product managers.

At TabExp Apps, we constantly hear questions from a lot of users on how they can automate remote desktop logins using PowerShell scripts and believe it when we say that the automation scripts and commands we’re sharing in this article with you can be easily executed using Azure DevOps whether or not you possess any automation knowledge and skills.

Other similar post: Automate SQL Database backups and restores

Below is a step-by-step guide with PowerShell Scripts for executing auto logins to remote machines and exporting Windows roles and features:

Step 1: Remote Session
Enable-PSRemoting –Force
$Username = “Username”
$Password = ConvertTo-SecureString “<secretkey>” -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential
-argumentlist $username, $password
Enter-PSSession -ComputerName <remotemachineIP> -Credential $cred
$Username = “<loginusername>”
$Password = ConvertTo-SecureString “<SecretKey>” -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential –
argumentlist $username, $password
New-PSDrive -Name “K” -Root “\\\common\88”
-Persist -PSProvider “FileSystem” -Credential $cred
Import-Module ServerManager
Get-WindowsFeature | ? { $_.Installed } | Export-Clixml k:\Features.xml
Step 2: Web API Install
$url = “”
$output = “$PSScriptRoot\WebPlatformInstaller_x64_en-US.msi”
$start_time = Get-Date
Invoke-WebRequest -Uri $url -OutFile $output
Write-Output “Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)”
Invoke-Command -ScriptBlock { & cmd /c “Msiexec /i $PSScriptRoot\WebPlatformInstaller_x64_en-US.msi” /log C:\MSIInstall.log }
Step 3: Web Deploy
& “C:\Program Files\Microsoft\Web Platform Installer\WebpiCmd-x64.exe” /install /Products:WDeployNoSMO /AcceptEULA
Step 4: Webserver backup
Add-PSSnapin WDeploySnapin3.0
Backup-WDServer “K:\IIS”
And you’re done!

With broad expertise in Azure DevOps and Automation Services, the expert automation engineers at TABEXP Apps have rendered support to a number of software development companies, have helped them automate several cloud operations, and accelerate time-to-market. Get in touch with us to automate your workloads.

Our Recent Posts

Database Backup & Restore

Microsoft SQL is the most widely used database management system. As a user, you put huge amount of data there. Using this popular database is easy but its maintenance and backup is not.

A key player from the manufacturing industry performs legacy application migration to the Azure cloud. TabExp Apps builds an Azure SaaS module solution & Azure IoT solution.

A multinational chain of hospitals in the USA performs an Azure database migration as a solution for higher data protection and security while meeting the regulatory compliances.

Leave a Reply