13. December 2013 00:12
/
Martin Poisel
/
Comments (0)
We are using Mikrotik routers as VPN servers for our Windows clients (XP, 7, 8). As you know, you can use your VPN connection as default gateway and route all traffic through your corporate network (default option) or disable remote default gateway and use yot VPN connection without any routing (usable in small scenarios, where you have very small corporate network with few servers and one IP subnet bridged with your vpn clients. None of these two options is suitable for bigger corporates. We need to route internet traffic through actual default gateway and have some static routes to corporate network. add classless route, but you have to use Microsoft RRAS (or any other compatible VPN servers, that can assign IPs via DHCP). Unfortunattly, Mikrotik uses custom IP pools and there is no way, how to send custom IP routes to client. So I recently started using CMAK to build custom VPN install package, to be able to add some custom routes to corporate my network. This works fine on Windows 7 and 8 but not on XP. There is problem with default interfaces. Anytime, you connect with Windows XP, it adds custom routes, but it uses its default gateway as remote gateway (instead of VPN interface address), so routing does not work. After hours spend on google, where I found no solution, I made easy powershell script. Just add it to your CMAK package as custom action after VPN connected and all works well.
$IPAddress = (Get-wmiobject Win32_NetworkAdapterConfiguration |where {($_.Description -like '*PPP*') -and ($_.IPAddress -ne $null) } |select IPAddress).IPAddress; cmd /c "route add 1.1.1.0 mask 255.255.255.240 $IPAddress"
config.png (60.03 kb)
bd15e884-8a6e-4248-b3d2-a09bf541e83b|3|1.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
12. November 2013 21:30
/
Martin Poisel
/
Comments (0)
Would you like to make offsite VM backup along with Hyper-V Replica? Unfortunatelly, it is not supported by MS. If you start backuping VM Replica, replication could break.
The solution is (where hyperv-cluster1 is source and cluster2 is replica):
1) pause replication
Get-ClusterGroup -Cluster hyperv-cluster1.amccomp.cz | Where-Object {$_.GroupType -eq "VirtualMachine" -and $_.State -eq "Online"} | Get-VM | Where-Object {$_.ReplicationMode -eq "Primary" -and $_.ReplicationState -eq "Replicating"} | Suspend-VMReplication
2) make backup
DPM, Windows Backup or your favourite backup tool
3) resume replication
Get-ClusterGroup -Cluster hyperv-cluster2.amccomp.cz | Where-Object {$_.GroupType -eq "VirtualMachine" -and $_.State -eq "Offline"} | Get-VM | Where-Object {$_.ReplicationMode -eq "Replica" -and ($_.ReplicationState -eq "Suspended" -or $_.ReplicationState -eq "Error")} | Resume-VMReplication
Get-ClusterGroup -Cluster hyperv-cluster2.amccomp.cz | Get-ClusterResource | Where-Object {$_.ResourceType -eq "Virtual Machine Configuration" -and $_.State -eq "Offline"} | Start-ClusterResource
Get-ClusterGroup -Cluster hyperv-cluster1.amccomp.cz | Where-Object {$_.GroupType -eq "VirtualMachine" -and $_.State -eq "Online"} | Get-VM | Where-Object {$_.ReplicationMode -eq "Primary" -and ($_.ReplicationState -eq "Suspended" -or $_.ReplicationState -eq "Error")} | Resume-VMReplication
Don't forget to take cluster resources on replica cluster online (because replica supendation takes them offline). This solution would also work without cluster (just start useing from Get-VM ...).
You can use my Powershell scripts below:
pause-replication.ps1 (259.00 bytes)
pause-replication.ps1 (259.00 bytes)
6dfa6906-45ce-4e9d-aaf8-2f46a313c8ad|2|3.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
12. November 2013 21:16
/
Martin Poisel
/
Comments (1)
Our company's IS has database with customer computers and their fqdn addresses. We used to have binnary .rdp files stored in sql database along with other informations. It was very sticky and lengthy to insert new records and upload new .rdp files and everybody was lazy to do that.
So I decided to write some solution to dynamicly generate .rdp files from my IS. Here is simple handler.
<%@ WebHandler Language="C#" Class="RDP" %>
using System;
using System.Web;
public class RDP : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.AddHeader("Content-Type", "application/rdp");
context.Response.AddHeader("Content-Disposition", "attachment; filename=map.rdp");
context.Response.Write("screen mode id:i:2\n");
context.Response.Write("use multimon:i:0\n");
context.Response.Write("desktopwidth:i:1920\n");
context.Response.Write("desktopheight:i:1200\n");
context.Response.Write("session bpp:i:32\n");
context.Response.Write("winposstr:s:0,1,0,0,800,600\n");
context.Response.Write("compression:i:1\n");
context.Response.Write("keyboardhook:i:2\n");
context.Response.Write("audiocapturemode:i:0\n");
context.Response.Write("videoplaybackmode:i:1\n");
context.Response.Write("connection type:i:2\n");
context.Response.Write("displayconnectionbar:i:1\n");
context.Response.Write("disable wallpaper:i:1\n");
context.Response.Write("allow font smoothing:i:0\n");
context.Response.Write("allow desktop composition:i:0\n");
context.Response.Write("disable full window drag:i:1\n");
context.Response.Write("disable menu anims:i:1\n");
context.Response.Write("disable themes:i:0\n");
context.Response.Write("disable cursor setting:i:0\n");
context.Response.Write("bitmapcachepersistenable:i:1\n");
context.Response.Write("full address:s:" + context.Request.QueryString["RDPAddress"] + "\n");
context.Response.Write("audiomode:i:0\n");
context.Response.Write("redirectprinters:i:1\n");
context.Response.Write("redirectcomports:i:0\n");
context.Response.Write("redirectsmartcards:i:1\n");
context.Response.Write("redirectclipboard:i:1\n");
context.Response.Write("redirectposdevices:i:0\n");
context.Response.Write("redirectdirectx:i:1\n");
context.Response.Write("autoreconnection enabled:i:1\n");
context.Response.Write("prompt for credentials:i:0\n");
context.Response.Write("negotiate security layer:i:1\n");
context.Response.Write("remoteapplicationmode:i:0\n");
context.Response.Write("alternate shell:s:\n");
context.Response.Write("shell working directory:s:\n");
context.Response.Write("gatewayhostname:s:" + context.Request.QueryString["RDPGateway"] + "\n");
context.Response.Write("gatewayusagemethod:i:2\n");
context.Response.Write("gatewaycredentialssource:i:0\n");
context.Response.Write("gatewayprofileusagemethod:i:1\n");
context.Response.Write("promptcredentialonce:i:1\n");
context.Response.Write("use redirection server name:i:0\n");
context.Response.Write("drivestoredirect:s:\n");
context.Response.Write("networkautodetect:i:1\n");
context.Response.Write("bandwidthautodetect:i:1\n");
context.Response.Write("enableworkspacereconnect:i:0\n");
context.Response.Write("rdgiskdcproxy:i:0\n");
context.Response.Write("kdcproxyname:s:\n");
context.Response.End();
}
public bool IsReusable {
get {
return false;
}
}
}
RDP.ashx (3.30 kb)
ed54380e-2124-426c-9ed4-a75c40e0b913|2|3.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
23. September 2013 09:40
/
Martin Poisel
/
Comments (4)
If you need migrate your existing Gen1 VM to Gen2 VM, there is simple solution. You don't need double take move (or any other 3rd party sw). Just trun of your VM (make backup!!) and start conversion.
- Backup
- Note IP config and license key. New VM will have new NICs and new hardware IDs. Maybe you can edit VM .xml configs and copy & paste HW IDs, but I haven't tried it yet and not sure if it will work (but I think it should).
- Turn off BitLocker and decrypt your drives (if you are using)
- Turn off VM
- Mount VHD in your Host OS
- Convert VHD from MBR to GPT with gptgen: http://sourceforge.net/projects/gptgen/
- Delete System Reserved partition
- Create UEFI partitions
- create partition EFI size=100 offset=1
- format quick fs=fat32 label="System"
- assign letter=S (don't use ntfs, it won't work!)
- create partition msr size=128 offset=103424
- Repair booting: bcdboot c:\windows /s s: /f UEFI
- Create new Gen2 VM and attach your edited VHD
- Boot Gen2 VM (you can also switch on secure boot)
- Reapair networking, reactivate OS
- Enjoy faster booting and online System VHD resizing.
9f2a8232-1d55-40c3-99ed-352ac1c2a497|4|4.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Many years ago, I decided to write my own blog, about "original IT solutions" from MS world. Finally, I made it.
c3b491e5-59ac-4f6a-81e5-27e971b903ed|8|3.8|96d5b379-7e1d-4dac-a6ba-1e50db561b04