How to RDP connect to an Azure VM - azure

I would like to run some tests on some VM machines. The machines belong to different users with different MSDN accounts, which means private passwords.
What I did was so far is to create an Azure VM for each MSDN account and set a similar user name/password for the machine.
What I would like to do is to:
Connect to any of these VMs. My problem: I don't know the machine name. I tried to connect using the rdp file provided by Azure, and it's working, but the problem is that it's using an IP instead of a name.
I tried finding the machine name, but all documentation about this seems to be outdated. . I tried to connect to amam10x64.westeurope.cloudapp.azure.com but without success.
Copy a file to/from the VM. My hope is that I can use the following snippet:
$commandStr = [string]::Format("Copy-VMFile ""{0}"" -SourcePath ""{1}"" -
DestinationPath ""{2}"" -CreateFullPath -FileSource Host -Force", $VM,
$SessionPath, $RemoteFullPath)
$commandBlock = [scriptblock]::Create($commandStr)
Invoke-Command -Session $sess -ScriptBlock $commandBlock
Run a command on the VM. Hopefully, I can use same command from Pt. 2.

I tried to connect to amam10x64.westeurope.cloudapp.azure.com but
without success.
If you want to connect this VM with DNS, we should set FQDN for this VM, please refer to this link.
Copy a file to/from the VM. My hope is that I can use the following
snippet:
Maybe we can use winrm to do this.
About how to use winrm connect Azure VM, please refer to this answer.
Run a command on the VM. Hopefully, I can use same command from Pt. 2.
We can use this script to connect Azure VM via Winrm:
$username = 'jason'
$pass = ConvertTo-SecureString -string 'password' -AsPlainText -Force
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $pass
$s = New-PSSession -ConnectionUri 'http://23.99.82.2:5985' -Credential $cred -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck)
Invoke-Command -Session $s -ScriptBlock {Get-Process PowerShell}

Related

Disable Network Level Security on my Azure Virtual machine remotely

Whenever I try to login in my Server I get following error
The remote computer that you are trying to connect to requires Network Level Authentication (NLA), but your Windows domain controller cannot be contacted to perform NLA. If you are an administrator on the remote computer, you can disable NLA by using the options on the Remote tab of the System Properties dialog box.
I cant connect to my server remotely using powershell and Remote registry(regedit) inspite of enabling TCP port 5986. Can any one suggest a solution.
There is an easy method to disable NLA via the Azure portal. You can navigate the Operation---Run command---select the DisableNLA script, then click Run button after finishing the run command script, restart your Azure VM for the change to take effect.
Alternatively, you also could invoke run command with PowerShell or Azure CLI.
https://learn.microsoft.com/en-us/azure/virtual-machines/windows/run-command
For example
Run these PowerShell scripts to disable or enable the NLA of the remote computer on the local machine with Invoke-AzVMRunCommand -ResourceGroupName '<myResourceGroup>' -Name '<myVMName>' -CommandId 'RunPowerShellScript' -ScriptPath '<pathToScript>' -Parameter #{"arg1" = "var1";"arg2" = "var2"}
$ComputerName = "remote computer"
# Getting the NLA information
(Get-WmiObject -class "Win32_TSGeneralSetting" -Namespace root\cimv2\terminalservices -ComputerName $ComputerName -Filter "TerminalName='RDP-tcp'").UserAuthenticationRequired
# Setting the NLA information to Disabled
(Get-WmiObject -class "Win32_TSGeneralSetting" -Namespace root\cimv2\terminalservices -ComputerName $ComputerName -Filter "TerminalName='RDP-tcp'").SetUserAuthenticationRequired(0)
# Setting the NLA information to Enabled
(Get-WmiObject -class "Win32_TSGeneralSetting" -Namespace root\cimv2\terminalservices -ComputerName $ComputerName -Filter "TerminalName='RDP-tcp'").SetUserAuthenticationRequired(1)
# -Parameter #{"arg1" = "var1";"arg2" = "var2"}
Result

Running powershell/powercli scripts in VMware VCenter connection automation

I'm running a set of powerCLI scripts from Ubuntu to connect to VCenter do a bunch of configuration changes. Every script is invoked via SSH, so it is connecting and disconnecting to the VCenter everytime. This is rather time consuming, is it possible to setup powerCLI/powershell environment to connect to a VCenter automatically? Or, maintain a session of a powerCLI/powershell so remote connections can re-use it? One possibility is to use "screen" command to share the session, but i'm hoping someone has a more elegant idea.
You can use PowerCLI6.5.1 to do most of what you are asking. Install
from the PowerShell gallery.
Find the Module
Find-Module -Name VMware.PowerCLI
Install
Install-Module -Name VMware.PowerCLI –Scope CurrentUser
if you run into an error during installation I fixed it with AllowClobber "-AllowClobber" command
Import-Module VMware.PowerCLI
A couple of examples
Connect-VIServer "Server" -SessionId $sessionId
Connect to a server and save the session ID - $serverObject.SessionId You will be able to restore a existing server connection.
Connect-VIServer "Server" -User user -Password pass -SaveCredentials
Will save the credentials to the credential store. That way you can reuse them and they are encrypted.
See here for more info
https://blogs.vmware.com/PowerCLI/2017/04/powercli-install-process-powershell-gallery.html

Can't Log into Azure Virtual Machine created w/ Resource Manager

I just created a VM in Azure using the Resource Manager model. And I can't RDP to it. The machine is running. The error I receive is:
Your credentials did not work
I have tried the following user names:
myCompanyDomain\user
user
.\user
\user
NameOfVM\user
I have checked, double checked, and tripple checked the password. I have read and followed all of the steps in this article: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-troubleshoot-remote-desktop-connections/#wincred
Still can't connect. What am I missing?
Well, the root of this problem is still a mystery. If we figure it out, I'll post the solution. For whatever weird reason, when I create a VM, nobody (none of my co-workers nor I) can access it. When anyone else creates a VM using the SAME STEPS, we can all access it. But, we found a work around. This article helped, but didn't get us all the way there.
Here's the work around script:
Login-AzureRmAccount
Get-AzureRmSubscription -SubscriptionName <Your Subscription Name>
Copy the Tenant Id returned above
Login-AzureRmAccount -TenantId <TenantId>
$vm = Get-AzureRmVM -ResourceGroupName <Your Resource Group Name> -Name <Your VM Name>
$cred = Get-Credential (this is the VM user credentials)
Set-AzureRmVMAccessExtension -ResourceGroupName <Your Resource Group Name> -VMName <Your VM Name> -Name VMAccessAgent -TypeHandlerVersion "2.0" -UserName $cred.UserName -Password $cred.GetNetworkCredential().Password -Location <Location of VM>
Update-AzureRmVM -ResourceGroupName <Your Resource Group Name> -VM $vm

Backup files from linux vm in Azure

I have been tasked with backing up certain files the exist on a Linux VM in azure to an azure backup vault.
I'm following the follwing documentation :-
http://azure.microsoft.com/en-gb/documentation/articles/backup-configure-vault/
However i can't see a backp agent for a linux box?
Am i missing something?
T
I don't believe there's a backup agent for Linux. You would use your standard backup/restore strategy here, for example rsync if it's just files or Bacula for something else. However, if the files absolutely need to be in the vault (say, because there are Windows Server VMs that need to use them) then I would suggest you use Azure Files to get the files out of Linux, then back them up from the Windows VMs. You can of course scp them, or use other methods. HTH.
This is what I had to do in a CentOS VM (credit goes to this serverfault answer).
Install the agent in the VM via SSH terminal:
wget https://raw.githubusercontent.com/Azure/WALinuxAgent/WALinuxAgent-2.0.12/waagent
chmod +x waagent
sudo cp waagent /usr/sbin
sudo /usr/sbin/waagent -install -verbose
sudo service waagent restart
Then I had to run the following cmdlets in an Azure PowerShell window, in order to flag the agent as installed:
$vm = Get-AzureVM -ServiceName 'myAzureServiceName' -Name 'myAzureVMName'
$vm.GetInstance().ProvisionGuestAgent = $true
Update-AzureVM -ServiceName 'myAzureServiceName' –Name 'myAzureVMName' -VM $vm.VM

Office 365 migration practice with windows azure

I have been asked to "help" a client migrate their on premise AD/Exchange 2010 implementation to the cloud (office 365).
i have no idea where to start and although I have watched quite a few videos on the topic via technet I feel I need some practical experience.
As such I was wondering if anyone knew of some step-by-step guides on how to setup a mock environment on windows azure (setting up a new AD server with multiple users) and then migrating that environment into office 365?
I would certainly recommend setting up a lab environment on Azure IaaS so that you can walk through the process.
Here's the basic process I use...
Set up a new Virtual Network via the Portal
Create an affinity group to ensure that resources are co-located
Create a storage account to host your VHD's
Create a PowerShell script to set up an AD VM
Install AD DS on the AD VM and configure your domain
Create PowerShell scripts for other domain-joined VM's
If you want federated authentication, create an AD FS VM
Create a VM to host DirSync
Configure directory synchronisation in Office 365
Install DirSync from the Office 365 portal on your DirSync VM
Create a VM to act as a test client or configure point-to-site VM and add an existing machine to your lab domain
Here's an example script to create an AD VM...
Import-Module "C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1"
Import-AzurePublishSettingsFile 'C:\Lab\credentials.publishsettings'
Set-AzureSubscription -SubscriptionName '{your Azure subscription}' -CurrentStorageAccount {your storage account name}
Select-AzureSubscription -SubscriptionName '{your Azure subscription}'
#Deploy the Domain Controller in a virtual network
#-------------------------------------------------
#Specify my DC's DNS IP (127.0.0.1)
$myDNS = New-AzureDNS -Name 'LabDNS' -IPAddress '127.0.0.1'
$vmname = 'LabDC'
# OS Image to Use
# Get the latest Windows Server 2008 R2 SP1 image
$family = "*Windows Server 2008 R2 SP1*"
$images = Get-AzureVMImage `
| where { $_.ImageFamily -like $family } `
| Sort-Object -Descending -Property PublishedDate
$image = $images[0].ImageName
Write-Host "Using image: " + $image
Read-Host "Continue or Ctrl-C to cancel"
$service = 'LabDomain'
$AG = 'LabAffinityGroup'
$vnet = 'LabNetwork'
$user = "LabAdmin"
$password = 'LabPassword123'
$subnet = 'Subnet-1'
#VM Configuration
$MyDC = New-AzureVMConfig -name $vmname -InstanceSize 'Small' -ImageName $image |
Add-AzureProvisioningConfig -Windows -AdminUsername $user -Password $password |
Set-AzureSubnet -SubnetNames $subnet
New-AzureVM -ServiceName $service -AffinityGroup $AG -VMs $MyDC -DnsSettings $myDNS -VNetName $vnet

Resources