pátek 15. května 2020

Virtual Machine time synchronization in Hyper-V

Get-VMIntegrationService -VMName * -Name "Time Synchronization" | Disable-VMIntegrationService

středa 19. února 2020

Oprava DFS replikace

For /f %i IN ('dsquery server -o rdn') do @echo %i && @wmic /node:"%i" /namespace:\\root\microsoftdfs path dfsrreplicatedfolderinfo get replicationgroupname,replicatedfoldername,state

The "state" values can be any of the following:
0 = Uninitialized
1 = Initialized
2 = Initial Sync
3 = Auto Recovery
4 = Normal
5 = In Error

 For /f %i IN ('dsquery server -o rdn') do @echo %i && @wmic /node:"%i" /namespace:\\root\microsoftdfs path DfsrMachineConfig get MaxOfflineTimeInDays

For /f %i IN ('dsquery server -o rdn') do @echo %i && @wmic /node:"%i" /namespace:\\root\microsoftdfs path DfsrMachineConfig set MaxOfflineTimeInDays=300


Zdroj: https://support.microsoft.com/en-us/help/2958414/dfs-replication-how-to-troubleshoot-missing-sysvol-and-netlogon-shares 

středa 7. listopadu 2018

Transfer FSMO rolí

Repadmin /syncall /e /d /A /P /q
repadmin /replsum /bysrc /bydest /sort:delta
Move-ADDirectoryServerOperationMasterRole -Identity NEW-PDC01 -OperationMasterRole SchemaMaster, DomainNamingMaster, PDCEmulator, RIDMaster, InfrastructureMaster

středa 30. května 2018

Zmenšení velikosti VHD

diskpart
select vdisk file="d:\store\vdisk.vhdx"
attach vdisk
list vol
sel vol X
shrink querymax
shrink desired=262144
detach vdisk
exit

Resize-VHD -Path d:\store\vdisk.vhdx -ToMinimumSize

středa 10. ledna 2018

Úplná obnova serveru na stejný nebo úplně jiný hardware

A server that is not a domain controller has gone for a burton, the whole server is a melted heap, or is gently rocking back and forth in the corner muttering about its childhood. You need to restore the whole server. I’m assuming at this point you have a replacement server you can use, this might be the same hardware with a component replaced (similar), or a brand new server (dissimilar).
These instructions have been tested on a Dell PowerEdge R410 Server with a H200 RAID controller and a Dell PowerEdge R410 Server with a SAS6i RAID controller, both running Microsoft Windows 2008 R2, although the procedure is the same for Microsoft Windows 2012 server.
1. Hook up the server, connect a monitor, keyboard and mouse (or use a KVM), start the server up and insert the Windows 2008 R2 Disc (which should have the same service pack slipstreamed in as the server you are restoring.)
2. If you need any RAID or Network card drivers you should have these on a USB memory stick, you may or may not need these depending on if your server has a generic Windows driver support or not. Either way prepare this if you need it.

3. Power up the server, ensure it boots up and configure the RAID to how you want it.
NOTE: The hard disk space on the server you are recovering to must be the same size or larger than that from which you took the backup. I.e. if you had a 100GB server, you can restore to a server with 100GB disk space or larger, you can’t restore a server with 60GB disk space.

4. Boot off the Microsoft Windows 2008 R2 DVD you have shoved in the drive. Wait for it to get to the Windows Setup screen.

5. Once it’s booted, select the “Time and Currency Format” as English (United Kingdom) and the “Keyboard” as UK and click on next.

6. Rather than clicking on “Install Now”, you should click on the “Repair your Computer” button in the bottom left of the screen.
7. Select “Restore your computer using a system image that you created earlier” and click on “Next >”
NOTE: If you need to load a driver you should do it now, by clicking on “Load Drivers” and shoving in the USB memory stick.
8. When prompted click on “Select a System Image” and click on “Next >” you should then see the images on the USB hard disk, click the one you want, then click on “Next >.”

9. Now you’ll see the recovery points (if there’s more than one) for your server, with the times. In our example, we have two of the buggers. Let’s use the oldest one in this case, so click on the one you want, then click “Next >.”



10. Now you’re prompted to “Format and repartition disks”, you should do this unless you really have a reason not to. This will wipe the kack of the server so your restore will be as clean as possible. If say you had data on a separate disk you don’t want wiping click on “Exclude disks..” and tick the drive you want excluding.
11. You might want to add extra drivers, now is the time to do this, click on “Install Drivers…” and select the driver files from a USB memory stick. “Advanced…” allows you to specify extra options, unless you have a reason to you don’t need to change these.
 
12. Click on “Next >” then review you have the correct backup selected, then click on “Finish” to start the ball rolling. Confirm by clicking on “Yes” and your server will start to restore. It will reboot when it’s all done.
Time for a cuppa!
13. Once the restoration has been completed, the server will reboot itself, and if all is well will boot up into your newly restored Windows image.

Oh, Balls!

 Blue Screen of Death
STOP: 0x0000007B (0xFFFFF880009A9928,0xFFFFFFFFC0000034,0x00000000000000000, 0x00000000000000000)


Now what, it appears that the 0x00000007B means “Inaccessible Boot Device”, in this example this is caused because we’ve gone from a R410 with a H200 RAID controller to a R410 with a SAS6i RAID controller, it doesn’t like it, we therefore need to make some changes to the server to make it boot.

14. Right, the fecker isn’t working, so when it reboots, you should find that it ends up at the “Windows Error Recovery” screen as shown below:

If it doesn’t come up, you should boot off the Windows 2008 R2 disc instead, but if you do this you’ll need to wait until you get to the Windows setup screen, and then press Shift F10 to get a command prompt, then carry on as below.

15. Select “United Kingdom” as the keyboard method, then click on “Next >” you’ll then be prompted for the Administrator password of the server. Now on a member server this is just the local administrator account password, on a domain controller, this is the restore mode password. Enter it and click on “Next >” to continue.
16. Click on “Command Prompt” from the set of three options.


 A quick aside: To disable the auto-reboot function so you can have a good butchers at the BSOD, you need to open the registry, to do this perform these steps:
1. Open Command Prompt.
2. regedt32
3. Highlight HKEY_LOCAL_MACHINE, File>Load Hive>[restored volume]:\Windows\System32\Config\SYSTEM
->Open->Key Name = Restored_HKLM>OK.
4. Expand Restored_HKLM\ControlSet001\Control\CrashControl and ensure the “AutoReboot” DWORD value has been set to 0 (setting it to 0 means autoreboot is turned off) then click OK.
5. Click on the “Restored_HKLM” hive and then select File>Unload Hive to disconnect from the registry.
6. Reboot the server and you’ll see the BSOD in all its shitty glory.
17. Now perform the following steps within the command prompt:
 1. regedt32
2. Highlight HKEY_LOCAL_MACHINE, File>Load Hive>[restored volume]:\Windows\System32\Config\SYSTEM>Open>Key Name = Restored_HKLM>OK.

3. Expand Restored_HKLM\ControlSet001\services and ensure the following keys “Start” are set to 0 (zero) instead of whatever value they currently have. You are basically turning them all on by setting it to 0 (zero.)
aliide (changed),
amdide (changed),
atapi,
cmdide (changed),
iastorv (changed),
intelide (changed),
msahci (changed),
pciide,
viaide (changed),
LSI_SAS (changed).

 If restored to a (VMWare) VM then ensure intelide>Start = 0 and LSI_SAS>Start = 0; msahci>Start = 3 and pciide>Start = 3
NB: I have only tested this with VMWare VMs (Player/Workstation and vSphere) but will likely translate across to Microsoft (e.g. HyperV) VMs. The LSI_SAS value is definitely required, I couldn't boot in a VM until this was changed to 0.

Or if restoring to a physical machine with native HDD controller  then ensure msahci>Start = 0 and pciide>Start = 0; intelide>Start = 3 and LSI_SAS>Start = 3
4. Highlight Restored_HKLM and then File>Unload Hive.
5. Close windows and restart.
This is discussed here in more detail
Note: Turning them all on, isn’t the best thing, but it will get the server up, you should then experiment by turning each one off one by one (i.e. setting it to 3) until you stop the server booting, we don’t want stuff running that we don’t actually use.

18. Okay bitching, we are cooking on gas now! We have it booting up.


19. The server is up and running, you should now login to ensure all is well. You’ll need to logon locally, because the network card settings may have gone walkabout and you’ll need to reconfigure them.
20. Go to the command prompt.
 1. Type: ” SET DEVMGR_SHOW_NONPRESENT_DEVICES=1 “ and press
2. Type: ” Start devmgmt.msc ” and press
3. In the Device Manager go to View and click on ” Show Hidden Devices “
4. Navigate to the Network Adapters and expand it, there should be your old NIC
5. Select and delete.
6. Remove all the NICs (even the live ones), then rescan for new devices.
By doing the above you'll remove the old NICs from the image, these will have been from the server from which you imaged from. If of course you are restoring onto the identical hardware this is unlikely to be the case. its good to get rid of these ghost adapters because they can cause problems.

21. Now the devices will have re-appeared, you just need to configure their network settings as per the old server configuration. Disable any unused NICs to avoid weird-ness.
22. Reboot the server to confirm, and that’s it, you should have your server working again. It is advised that you check everything and then troubleshoot any errors, but as this is an image of the server, then these should be minimal unless of course you are restoring a domain controller, in which case you have more to do.
NOTE: if this server is staying in production, don’t forget to turn off the unneeded services from step 17. This is trial and error.


středa 15. listopadu 2017

Řešení duplicity při synchronizaci AD s Azure AD

$AD_Username = "uzivatelske.jmeno";
$DELETE_UPN = "uzivatelske.jmeno@domena.cz";
$Azure_UPN = "email@domena.cz";

$guid = (get-Aduser $AD_Username).ObjectGuid
$immutableID = [System.Convert]::ToBase64String($guid.tobytearray())
Install-Module MSOnline
Import-Module MSOnline
Connect-MSOLService
$DELETE_UPN
Get-MsolUser -UserPrincipalName $DELETE_UPN | Remove-MsolUser
Remove-MSOLuser -UserPrincipalName $DELETE_UPN -RemoveFromRecycleBin
Set-MSOLuser -UserPrincipalName $Azure_UPN -ImmutableID $immutableID
Start-ADSyncSyncCycle -PolicyType Delta

pátek 31. března 2017

Vyčištění disku na serveru bez instalace Desktop Experience

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.0.6001.18000_none_c962d1e515e94269\cleanmgr.exe C:\Windows\System32\
copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.0.6001.18000_cs-cz_769ec0156a09da94\cleanmgr.exe.mui C:\Windows\System32\cs-CZ\

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe C:\Windows\System32
copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_cs-cz_76751638cb5d7005\cleanmgr.exe.mui C:\Windows\System32\cs-CZ\

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.2.9200.16384_none_c60dddc5e750072a\cleanmgr.exe C:\Windows\System32
copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.2.9200.16384_cs-cz_7349cbf63b709f55\cleanmgr.exe.mui C:\Windows\System32\cs-CZ\

pátek 26. srpna 2016

Bezobslužné instalace programů


  • SetupPohodaCZ_Start_10301.exe /S /v/qn iview432_setup.exe /silent /group=1 /allusers=1 /assoc=1 vlc-2.0.0-win32.exe /S
  • gimp-2.6.12-i686-setup-2.exe /VERYSILENT /NORESTART
  • OOo_3.3.0_Win_x86_install-wJRE_cs.exe /S /GUILEVEL=qn
  • 7z920.exe /S /GUILEVEL=qn


Adobe Reader: ftp://ftp.adobe.com/pub/adobe/reader/win/11.x/11.0.00/cs_CZ/

Zdroje: http://www.appdeploy.com

pondělí 7. září 2015

Obnovení smazaného objektu Active Directory

Get-ADObject -Filter {Name -like "*Novak*"} -IncludeDeletedObjects | Restore-ADObject -NewName novak

pátek 31. července 2015

Tooly pro Hyper-V

$wc=new-object system.net.webclient
$wc.downloadfile("http://totalcommander.ch/win/tcmd900ax64.exe","c:\tcmd.exe")
$wc.downloadfile("http://probus-it.zohosites.com/files/HVTools2.05.zip","c:\HVTools2.05.zip")
$wc.downloadfile("http://ftp-stahuj.centrum.cz/dl/74db9832f37e08b93e66e65f61f12d97/56436745/stahuj/download/software/secured/h/hd-speed/178107/64-bit/HD_Speed_ENG_Win64.zip","c:\HD_Speed_ENG_Win64.zip")
$wc.downloadfile("http://osdn.jp/frs/redir.php?m=jaist&f=%2Fcrystaldiskinfo%2F63423%2FCrystalDiskInfo6_5_2.zip","c:\CrystalDiskInfo6_5_2.zip")
$wc.downloadfile("http://www.tmurgent.com/Tools/HyperV_Mon/HyperV_Mon_302.zip","c:\HyperV_Mon_302.zip")

pondělí 20. července 2015

Bakaláři - Migrace na jiný SQL server

http://www.bakalari.cz/websql.aspx

1) Pustit instalaci
2) Po instalaci zrušit konfiguračního průvodce
3) Překopírovat data ze zálohy
4) Vytvořit ODBC spojení
5) Přidat výjimku do FW
6) Nainstalovat kolální baka
7) Přidat ODBC Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\Bakalari] "Driver"="C:\\WINDOWS\\system32\\SQLSRV32.dll"
"Server"="SERVER"
"LastUser"="sa"
"Trusted_Connection"="No"

PC startup
copy /Y \\SERVER\install$\Bakalari\dll\*.* %WINDIR%\SysWow64\

Učitel logon
RegEdit /s \\SERVER\bakalari$\winlocal\bakalari.reg
copy \\SERVER\bakalari$\winlocal\*.lnk %userprofile%\Desktop\

úterý 23. června 2015

Remote Desktop Connection Manager

RDCMan manages multiple remote desktop connections. It is useful for managing server labs or large server farms where you need regular access to each machine such as automated checkin systems and data centers. It is similar to the built-in MMC Remote Desktops snap-in, but more flexible.

Download RDCMan

úterý 13. ledna 2015

Nasazení Windows pomocí MDT 2013

NTB / PC
  1. Nainstalovat vzorový PC (jen čistý systém s ovladači)
  2. Extrahovat ovladače pomocí Double Driver 
Server
  1. Instalovat a konfigurovat roli "Služba pro nasazení systému Windows" (WDS)
  2. Instalovat "Windows Assessment and Deployment Kit" (ADK) stáhnout
    Instalovat součásti: Deployment tools a Windows PE
  3. Instalovat "Microsoft Deployment Toolkit" (MDT) stáhnout
  4. Zkontrolovat aktualizace komponent v DeploymentWorkbench
  5. Instalovat komponenty ve stavu required
  6. Vytvořit DeploymentShare v DeploymentWorkbench
  7. Importovat obsah CD Windows do DeploymentWorkbench
  8. Importovat ovladače exportované v bodu 2 do DeploymentWorkbench
  9. Vytvořit Task sekvenci
  10. Upravit Bootstrap.ini a CustomSettings.ini popis parametrů
  11. Aktualizovat DeploymentShare
  12. Přidat spouštěcí (Lite touch) bitovou kopii (v DeploymentShare) do WDS
Další zdroje:

středa 29. října 2014

Rozložení provozu mezi dvě brány na Mikrotiku

If you have a number of hosts, you may group them by IP addresses. Then, depending on the source IP address, send the traffic out through Gateway #1 or #2. This is not really the best approach, giving you perfect load balancing, but it's easy to implement, and gives you some control too.
Let us assume we use for our workstations IP addresses from network 192.168.100.0/24. The IP addresses are assigned as follows:
  • 192.168.100.1-127 are used for Group A workstations
  • 192.168.100.128-253 are used for Group B workstations
  • 192.168.100.254 is used for the router.
All workstations have IP configuration with the IP address from the relevant group, they all have network mask 255.255.255.0, and 192.168.100.254 is the default gateway for them. We will talk about DNS servers later.
Now, when we have workstations divided into groups, we can refer to them using subnet addressing:
  • Group A is 192.168.100.0/25, i.e., addresses 192.168.100.0-127
  • Group B is 192.168.100.128/25, i.e., addresses 192.168.100.128-255
If you do not understand this, take the TCP/IP Basics course,
or, look for some resources about subnetting on the Internet!
We need to add two IP Firewall Mangle rules to mark the packets originated from Group A or Group B workstations.
For Group A, specify
  • Chain prerouting and Src. Address 192.168.100.0/25
  • Action mark routing and New Routing Mark GroupA.
Dual gw 22.jpg
It is a good practice to add a comment as well. Your mangle rules might be interesting for someone else and for yourself as well after some time.
For Group B, specify
  • Chain prerouting and Src. Address 192.168.100.128/25
  • Action mark routing and New Routing Mark GroupB
Dual gw 25.jpg
All IP traffic coming from workstations is marked with the routing marks GroupA or GroupB. We can use these marks in the routing table.
Next, we should specify two default routes (destination 0.0.0.0/0) with appropriate routing marks and gateways:
Dual gw 26.jpg

pátek 11. července 2014

Jak zapnout numlock při startu Windows


Windows Registry Editor Version 5.00

[HKEY_USERS\.DEFAULT\Control Panel\Keyboard]
"KeyboardSpeed"="31"
"InitialKeyboardIndicators"="2"
"KeyboardDelay"="1"

pondělí 7. července 2014

Uvolnění fronty Postfixu

Vše přesunout z incoming queue do hold queue

postsuper -h ALL

Pomocí skriptu:

#!/usr/bin/perl
 
$REGEXP = shift || die "no email-adress given (regexp-style, e.g. bl.*\@yahoo.com)!";
 
@data = qx</usr/sbin/postqueue -p>;
for (@data) {
  if (/^(\w+)(\*|\!)?\s/) {
     $queue_id = $1;
  }
  if($queue_id) {
    if (/$REGEXP/i) {
      $Q{$queue_id} = 1;
      $queue_id = "";
    }
  }
}
 
#open(POSTSUPER,"|cat") || die "couldn't open postsuper" ;
open(POSTSUPER,"|postsuper -d -") || die "couldn't open postsuper" ;
 
foreach (keys %Q) {
  print POSTSUPER "$_\n";
};
close(POSTSUPER);

smazat z fronty nechtěné maily

./postfix-delete.pl fackspamdomain.com

přesunout vše z hold queue zpět do incoming quue

postsuper -r ALL

neděle 11. května 2014

Oprava bootování virtuálky na Virtualmaster po upgrade kernelu

V rescue režimu

mount /dev/xvda /mnt

mount --bind /dev /mnt/dev
mount --bind /dev/pts /mnt/dev/pts
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys

chroot /mnt

grub-mkdevicemap

update-grub

exit
umount /mnt/dev
umount /mnt/dev/pts
umount /mnt/proc
umount /mnt/sys
umount /mnt

neděle 11. srpna 2013

Kódy pro nastavení přesměrování hovorů

Přesměrování při nedostupnosti
  • Aktivace přesměrování při nedostupnosti: **62*telefonní_číslo*11#
  • Deaktivace přesměrování při nedostupnosti: ##62#
  • Kontrola aktuálního nastavení: *#62#
Přesměrování při nepřijetí hovoru
  • Aktivace přesměrování při nepřijetí hovoru: **61*telefonní_číslo*11**prodleva#
  • Deaktivace přesměrování při nepřijetí hovoru: ##61#
  • Kontrola aktuálního nastavení: *#61#
Přesměrování při obsazení čísla (platí i pro odmítnutí hovoru)
  • Aktivace přesměrování při obsazení čísla: **67*telefonní_číslo*11#
  • Deaktivace přesměrování při obsazení čísla: ##67#
  • Kontrola aktuálního nastavení: *#67#
Nepodmíněného přesměrování
  • Aktivace nepodmíněného přesměrování: **21*telefonní_číslo#
  • Deaktivace nepodmíněného přesměrování: ##21#
  • Kontrola aktuálního nastavení: *#21#
Deaktivace všech nastavených přesměrování
  •  ##002#