Category: IT

  • Windows Robocopy Cheat Sheet

    Below is a basic cheat sheet of robocopy commands. Wanna go crazy? Here!
    Like a GUI?

    :: Source Directory :
    /SD:\\server1.domain.com\d$\Backups		:: Source Directory.
    
    :: Destination Directory :
    /DD:\\server2.domain.com\e$\Target :: Destination Directory.
    
    :: Include These Files :
    /IF :: Include Files matching these names
    :: *.* :: Include all names (currently - Command Line may override)
    
    :: Exclude These Directories :
    /XD :: eXclude Directories matching these names
    :: :: eXclude no names (currently - Command Line may override)
    
    :: Exclude These Files :
    /XF :: eXclude Files matching these names
    
    :: Copy options :
    :: /IPG:10 :: Inter-Packet Gap (ms), to free bandwidth on slow lines.
    /B :: copy files in Backup mode.
    /MIR :: MIRror a directory tree (equivalent to /E plus /PURGE).
    /SEC :: copy files with SECurity (equivalent to /COPY:DATS).
    /MT:20 :: Do multi-threaded copies with n threads (default 8)
    
    :: Retry Options :
    /R:5 :: number of Retries on failed copies: default 1 million.
    /W:5 :: Wait time between retries: default is 30 seconds.
    
    :: Logging Options :
    /V :: produce Verbose output, showing skipped files.
    /NP :: No Progress - don't display % copied.
    /FP :: replaces simple file names with full file pathnames in the output.
    /NDL :: (No Directory List) suppresses output of the directory list.
    /NFL :: (No File List) suppresses output of files processed.
    /TEE :: output to console window, as well as the log file.
    /LOG:D:\Robocopy\Scripts\robojob\log.txt :: output status to LOG file (overwrite existing log).
  • FreeNAS Useful Commands

    ZFS

    Code:
    zpool status -v #shows zpool status infos
    
    zpool iostat 1 #shows IOps and R/W bandwidth every second
    
    zfs list -t snapshot #lists all the snapshots, add | grep "" to filter
    
    arc_summary.py #shows ARC stats
    
    arcstat.py #shows ARC stats
    
    zdb -C your_pool_name | grep ashift #shows the ashift value

    SMART

    Code:
    smartctl -h #shows smart control help, lots of commands examples
    
    smartctl -a /dev/daX #shows all smart attributes
    
    smartctl -A /dev/daX #same as -a but without vendor infos, last test infos, ...
    
    smartctl -l selftest /dev/daX #shows result of last smart test
    
    smartctl -l scttemp /dev/daX #shows the temperatures history
    
    smartctl -t long /dev/daX #executes a long test (replace "long" by "short" for a short test)

    HDD

    Code:
    glabel status  #shows gptids and devices names
    
    gstat -f daX -I 1000ms #shows IOps and R/W bandwidth every second
    
    iostat daX #shows IOps and R/W bandwidth

    HBA

    Code:
    dmesg | grep mps #used to check FW and driver versions on HBA cards using the mps driver

    UPS

    Code:
    upsc ups #shows all ups attributes (change "ups" with your ups name)

    Misc

    Code:
    kldload ipmi.ko #loads ipmitool
    ipmitool sensor #shows all ipmi sensors values
    
    systat -vm #shows system infos (cpu load, ram usage, drives I/O, ...)
    
    dmidecode | more #shows all hardware bios infos
    
    cat /var/log/messages | more #shows the log (same as in the GUI footer)
    
    freenas-debug -h more /var/tmp/fndebug #shows all debug infos
    
    camcontrol devlist #shows all devices
    
    usbconfig #shows all usb devices

    Burn-in/Benchmark

    Code:
    dd if=/dev/zero of=/mnt/tank/tmp.zero bs=2048k count=50k #disable shares and compression for the test!!!
    dd if=/mnt/tank/tmp.zero of=/dev/null bs=2048k count=50k #disable shares and compression for the test!!! don't forget to delete tmp.zero after
    
    diskinfo -t daX #test seek and transfer times
    
    for i in 1 2 3 4; do while : ; do : ; done & done #cpu burn test for 4 threads
  • Migrate only VMDK to another Datastore without Vcenter.

    1. power off the VM
    2. make sure the VM doesn’t have active snashots!!! (i.e. no delta .vmdk files in the VM’s folder)
    3. create a new target folder on the destination datastore
    4. clone the virtual disk, using the following command
      vmkfstools -i /vmfs/volumes/source-ds/vm-folder/virtual-disk.vmdk /vmfs/volumes/target-ds/vm-folder/virtual-disk.vmdk
      if you want the destination virtual disk to become thin provisioned, append -d thin to the above command line
      for details see e.g. https://kb.vmware.com/s/article/1028042
    5. from the GUI, edit the VM’s settings, i.e. remove the migrated virtual disk from the VM’s configuration (do not yet select delete from disk), save the VM’s settings,, then open the settings again and add the existing virtual disk from the target location to the VM (make sure you select the same adapter, e.g. scsi0:1 to which the original virtual disk was connected)

    If everything works as expected you may then carefiully delete the obsolete/migrated virtual disk file(s) from the source datasatore.

  • Useful CMD and PowerShell Commands

    Just a collection of commands, use at your own risk!

    How to Permanently Remove Deleted Users from Office 365
    Connect-MsolService
    
    Get-MsolUser -ReturnDeletedUsers
    
    Remove-MsolUser -UserPrincipalName Lynn@office365bootcamp.com -RemoveFromRecycleBin
    
    Get-MsolUser -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin -Force
    
    How to copy a file to Hyper-V VM via Integration Services
    Copy-VMFile Win10 -SourcePath "File Location" -DestinationPath "File Location" -CreateFullPath -FileSource Host
  • Activate Office 2019 without any software.

    After a series of preview versions, Microsoft finally came out with an official version of Office 2019. It is stable one, this means you can download and use it right now without worrying about fatal errors which you have gotten in beta versions before. However, I regret to inform that according to the disclosures, Microsoft Office 2019 only works on Windows 10. So if you are using Windows 8 or older versions, you will not be able to install it. Honestly, I hate what Microsoft have done to force users to use Windows 10. And I think Office 2016 is still a good choice for casual users at the moment.

    How to download Office 2019 from Microsoft homepage

    If you have an Office 365 subscription, your Office will be upgraded to the latest version automatically without doing anything. However, if you are using Office 2016 or earlier versions, to make sure that Office 2019 will work normally, please uninstall your old version of Office completely before starting a new installation. If you do not have Office 2019 already, just go here to get official download link from Microsoft homepage and select the version you want.

    Installing Office 2019 without a product key

    After the download process is complete, you will get an image file. Just open it then run the setup file to install Office 2019 on your PC.

    Open Office 2019 setup file
    Open Office 2019 setup file
    UAC alert
    UAC alert

    This may take a while, please wait.

    Office 2019 installation progress
    Office 2019 installation progress

    Upon successful installation, you can open any Office program to verify some basic information.

    Just skip the “enter product key” window by clicking close button at the top right corner.

    Bypass "Enter your product key" modal
    Bypass “Enter your product key” modal
    Accept Microsoft license agreement
    Accept Microsoft license agreement

    And as you can see, I am using Office Professional Plus 2019 and the trial license will expire in 7 days.

    7-day trial license of Office 2019
    7-day trial license of Office 2019
    Important features are disabled
    Important features are disabled

    Activating Office 2019 using KMS license key

    Method 1: Running commands one by one manually

    Time needed: 1 minute.

    Manually activate your Office with legal KMS product key.

    1. Open command prompt in administrator mode.

      First, you need to open command prompt with admin rights, then follow the instruction below step by step. Just copy/paste the commands and do not forget to hit Enter in order to execute them.

    2. Open location of the Office installed on your PC
      cd /d %ProgramFiles%\Microsoft Office\Office16
      cd /d %ProgramFiles(x86)%\Microsoft Office\Office16

      If you install your Office in the ProgramFiles folder, the path will be “%ProgramFiles%\Microsoft Office\Office16” or “%ProgramFiles(x86)%\Microsoft Office\Office16”. It depends on the architecture of the Windows OS you are using. If you are not sure of this issue, don’t worry, just run both of the commands above. One of them will be not executed and an error message will be printed on the screen.

    3. Convert your retail license to volume one
      for /f %x in ('dir /b ..\root\Licenses16\ProPlus2019VL*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%x"

      If your Office is got from Microsoft, this step is required. On the contrary, if you install Office from a Volume ISO file, this is optional so just skip it if you want.

    4. Activate your Office using KMS client key

      Make sure your PC is connected to the internet, then run the following command.

      cscript ospp.vbs /setprt:1688
      cscript ospp.vbs /unpkey:6MWKP >nul
      cscript ospp.vbs /inpkey:NMMKJ-6RK4F-KMJVX-8D9MJ-6MWKP
      cscript ospp.vbs /sethst:kms8.msguides.com
      cscript ospp.vbs /act

      Here is all the text you will get in the command prompt window.

      C:\Windows\system32>cd /d %ProgramFiles%\Microsoft Office\Office16
       C:\Program Files\Microsoft Office\Office16>cd /d %ProgramFiles(x86)%\Microsoft Office\Office16
       The system cannot find the path specified.
       C:\Program Files\Microsoft Office\Office16>for /f %x in ('dir /b ..\root\Licenses16\ProPlus2019VL*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%x"
       C:\Program Files\Microsoft Office\Office16>cscript ospp.vbs /inslic:"..\root\Licenses16\ProPlus2019VL_KMS_Client_AE-ppd.xrm-ms"
       Microsoft (R) Windows Script Host Version 5.812
       Copyright (C) Microsoft Corporation. All rights reserved.
       ---Processing--------------------------
       Installing Office license: ..\root\licenses16\proplus2019vl_kms_client_ae-ppd.xrm-ms
       Office license installed successfully.
       ---Exiting-----------------------------
       C:\Program Files\Microsoft Office\Office16>cscript ospp.vbs /inslic:"..\root\Licenses16\ProPlus2019VL_KMS_Client_AE-ul-oob.xrm-ms"
       Microsoft (R) Windows Script Host Version 5.812
       Copyright (C) Microsoft Corporation. All rights reserved.
       ---Processing--------------------------
       Installing Office license: ..\root\licenses16\proplus2019vl_kms_client_ae-ul-oob.xrm-ms
       Office license installed successfully.
       ---Exiting-----------------------------
       C:\Program Files\Microsoft Office\Office16>cscript ospp.vbs /inslic:"..\root\Licenses16\ProPlus2019VL_KMS_Client_AE-ul.xrm-ms"
       Microsoft (R) Windows Script Host Version 5.812
       Copyright (C) Microsoft Corporation. All rights reserved.
       ---Processing--------------------------
       Installing Office license: ..\root\licenses16\proplus2019vl_kms_client_ae-ul.xrm-ms
       Office license installed successfully.
       ---Exiting-----------------------------
       C:\Program Files\Microsoft Office\Office16>cscript ospp.vbs /inslic:"..\root\Licenses16\ProPlus2019VL_MAK_AE-pl.xrm-ms"
       Microsoft (R) Windows Script Host Version 5.812
       Copyright (C) Microsoft Corporation. All rights reserved.
       ---Processing--------------------------
       Installing Office license: ..\root\licenses16\proplus2019vl_mak_ae-pl.xrm-ms
       Office license installed successfully.
       ---Exiting-----------------------------
       C:\Program Files\Microsoft Office\Office16>cscript ospp.vbs /inslic:"..\root\Licenses16\ProPlus2019VL_MAK_AE-ppd.xrm-ms"
       Microsoft (R) Windows Script Host Version 5.812
       Copyright (C) Microsoft Corporation. All rights reserved.
       ---Processing--------------------------
       Installing Office license: ..\root\licenses16\proplus2019vl_mak_ae-ppd.xrm-ms
       Office license installed successfully.
       ---Exiting-----------------------------
       C:\Program Files\Microsoft Office\Office16>cscript ospp.vbs /inslic:"..\root\Licenses16\ProPlus2019VL_MAK_AE-ul-oob.xrm-ms"
       Microsoft (R) Windows Script Host Version 5.812
       Copyright (C) Microsoft Corporation. All rights reserved.
       ---Processing--------------------------
       Installing Office license: ..\root\licenses16\proplus2019vl_mak_ae-ul-oob.xrm-ms
       Office license installed successfully.
       ---Exiting-----------------------------
       C:\Program Files\Microsoft Office\Office16>cscript ospp.vbs /inslic:"..\root\Licenses16\ProPlus2019VL_MAK_AE-ul-phn.xrm-ms"
       Microsoft (R) Windows Script Host Version 5.812
       Copyright (C) Microsoft Corporation. All rights reserved.
       ---Processing--------------------------
       Installing Office license: ..\root\licenses16\proplus2019vl_mak_ae-ul-phn.xrm-ms
       Office license installed successfully.
       ---Exiting-----------------------------
       C:\Program Files\Microsoft Office\Office16>cscript ospp.vbs /setprt:1688
       Microsoft (R) Windows Script Host Version 5.812
       Copyright (C) Microsoft Corporation. All rights reserved.
       ---Processing--------------------------
       Successfully applied setting.
       ---Exiting-----------------------------
       C:\Program Files\Microsoft Office\Office16>cscript ospp.vbs /unpkey:6MWKP >nul
       C:\Program Files\Microsoft Office\Office16>cscript ospp.vbs /inpkey:NMMKJ-6RK4F-KMJVX-8D9MJ-6MWKP
       Microsoft (R) Windows Script Host Version 5.812
       Copyright (C) Microsoft Corporation. All rights reserved.
       ---Processing--------------------------
      
       ---Exiting-----------------------------
       C:\Program Files\Microsoft Office\Office16>cscript ospp.vbs /sethst:kms8.msguides.com
       Microsoft (R) Windows Script Host Version 5.812
       Copyright (C) Microsoft Corporation. All rights reserved.
       ---Processing--------------------------
       Successfully applied setting.
       ---Exiting-----------------------------
       C:\Program Files\Microsoft Office\Office16>cscript ospp.vbs /act
       Microsoft (R) Windows Script Host Version 5.812
       Copyright (C) Microsoft Corporation. All rights reserved.
       ---Processing--------------------------
       Installed product key detected - attempting to activate the following product:
       SKU ID: 85dd8b5f-eaa4-4af3-a628-cce9e77c9a03
       LICENSE NAME: Office 19, Office19ProPlus2019VL_KMS_Client_AE edition
       LICENSE DESCRIPTION: Office 19, VOLUME_KMSCLIENT channel
       Last 5 characters of installed product key: 6MWKP
      
      
       ---Exiting-----------------------------
       C:\Program Files\Microsoft Office\Office16>

    Right now the Office is activated successfully.

    Office 2019 product activated
    Office 2019 product activated

     

    Guide has been tested working. Taken from: https://msguides.com/microsoft-software-products/office-2019.html