Regex

Samlade uttryck för att minnas dem helt enkelt 🙂

URLs
För att testa regex uttryck https://regex101.com

Exempel:
 	abc… 	Letters
	123… 	Digits
	\d 	Any Digit
	\D 	Any Non-digit character
	. 	Any Character
	\. 	Period
	[abc] 	Only a, b, or c
	[^abc] 	Not a, b, nor c
	[a-z] 	Characters a to z
	[0-9] 	Numbers 0 to 9
	\w 	Any Alphanumeric character
	\W 	Any Non-alphanumeric character
	{m} 	m Repetitions
	{m,n} 	m to n Repetitions
	* 	Zero or more repetitions
	+ 	One or more repetitions
	? 	Optional character
	\s 	Any Whitespace
	\S 	Any Non-whitespace character
	^…$ 	Starts and ends
	(…) 	Capture Group
	(a(bc)) 	Capture Sub-group
	(.*) 	Capture all
	(abc|def) 	Matches abc or def
	

Powershell 7 – pwsh.exe – a collection of things…

Installera:

Länk till alla varianter och releases på GitHub

Windows terminal kan också vara bra att nyttja 🙂 MsStore

URL: 7.1.0
https://github.com/PowerShell/PowerShell/releases/tag/v7.1.0

Msi x64 direkt länk:
https://github.com/PowerShell/PowerShell/releases/download/v7.1.0/PowerShell-7.1.0-win-x64.msi


URL: 7.03 Release
https://github.com/PowerShell/PowerShell/releases/tag/v7.0.3
https://github.com/PowerShell/PowerShell/releases/download/v7.0.3/PowerShell-7.0.3-win-x64.zip

URL: 7.02 Release

https://github.com/PowerShell/PowerShell/releases/tag/v7.0.2

Snabb MSI installation singel line

iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"
Linux singel line:
wget https://aka.ms/install-powershell.sh; sudo bash install-powershell.sh; rm install-powershell.sh

PowerShell 7-modulens kompatibilitet

Beskriver Windows modulers kompatibilitet med PS7.

Remoting Cross plattform SSH etc
https://www.thomasmaurer.ch/2019/04/setup-powershell-ssh-remoting-in-powershell-6/

Extend vhd, vhdx -> profiledisks…

Ja för att ändra vhd eller vhdx filer krävs denna , den drar in powershell pluginen..
Add-WindowsFeature –name RSAT-Hyper-V-Tools

Att ändra en disk (som inte är mountad) kör följande…

Resize-VHD –Path c:path-to-vhd-fileyour-VHD-file.vhd –SizeBytes 10GB

PÅ en maskin (tpy 202r2 eller likannde finns inte möjligheten.
Där får man nyttja diskpart.

diskpart
select vdisk file="C:\UPDs\UVHD-<SID>.vhdx"
expand vdisk maximum=20480
attach vdisk
list volume
select volume=<number of UPD volume from previous command>
extend
detach vdisk
exit

Unifi Cloudkey fixes

Uppgrading the unifi Cloudkey can sometimes make a mess out of things.
Detta kan fixa en uppgraderad firmware som inte riktigt svarar alls mer är via SSH…
Detta var nödvändig fix efteruppdatering av cloud key gen1 till v. 1.1.6

unifi_version=$(grep -io "We do not support upgrading from 5.*" /usr/lib/unifi/logs/server.log | grep -io "5.*" | cut -d'.' -f1-3 | sort -V | tail -n 1)
if [[ -n "${unifi_version}" ]]; then rm unifi_sysvinit_all.deb 2> /dev/null; wget https://dl.ui.com/unifi/${unifi_version}/unifi_sysvinit_all.deb && dpkg -i unifi_sysvinit_all.deb && rm unifi_sysvinit_all.deb; fi

Alternativt sätt

rm -rf unifi_sysvinit_all.deb

/dev/null; wget https://dl.ui.com/unifi/5.12.35/unifi_sysvinit_all.deb && dpkg -i unifi_sysvinit_all.deb && rm -rf unifi_sysvinit_all.deb

Windows 10 Reset local account

  1. Load the recovery and troubleshooting environment, e.g. by clicking on ”Repair your computer” during Windows Setup if you boot from Windows installation media.
  2. Select Troubleshoot > Command Prompt.
  3. Switch to the drive letter that Windows is installed on and there in the system32 directory, e.g. cd c:\windows\system32
  4. Type rename utilman.exe utilman.bak.
  5. Type copy cmd.exe utilman.exe.
  6. Restart the computer and boot from the Window installation this time.
  7. If you run Windows 10 version 1803 or earlier, click on the Ease of Access button to open a command prompt window.
  8. If you run Windows 10 version 1809 or later, do the following first:
    1. Hold Shift-key on the keyboard and click on the Power button to select Restart.
    2. After the Restart, hold down the Shift-key again and select Restart from the Power menu again to boot into startup repair.
    3. Select Troubleshoot > Advanced Options > Startup Settings > Restart
    4. When the Startup Settings screen appears after the Restart, select 8) Disable early launch anti-malware protection.
  9. Click on the Ease of Access button on the next start on the login screen to open the command prompt window.
  10. Type net user to display the names of all user accounts.
  11. Use the command net user [username] [password] to change the password of the account, e.g. net user martin qwerty123456 to change the password of the user martin to qwerty123456.

Win10 slipstreaming – Old News …

Is anyone slipstreaming anymore ? Perhaps not the cululative updates is rather taking the fuzz away …
Still saves the stepps here to remember them…

Get the updates from here
https://www.catalog.update.microsoft.com/Home.aspx

#1 List index numbers of wim/esd file.
dism /Get-WimInfo /WimFile:Sources\install.wim or \install.esd

#2 Use index # for the edition such as home, pro etc… and save it to desktop.
Once done, move it to Sources

dism /Export-Image /SourceImageFile:”Sources\install.wim” /SourceIndex:# /DestinationImageFile:”install.wim” /Compress:Max

#3 Add Windows updates to wim file
dism /mount-wim /wimfile:”Sources\install.wim” /mountdir:mount /index:1
dism /image:mount /add-package /packagepath:package
Dism /unmount-wim /mountdir:mount /commit

Hidden Aruba console command.

  • log in (console, telnet, SSH, etc.) to the CLI
  • type ”edomtset” and hit enter
  • type ”edomtset” and hit enter (yes, again)
  • the prompt will change from ”#” to ”$”
  • hit ? to see what you can do
  • type ”exit” and hit enter when you´re done

    Why you shall need it … i dont know… but probably not safe…

Adobe acrobat ProtectedMode on RDS

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Adobe\Acrobat Reader\DC\FeatureLockDown]
”bProtectedMode”=dword:00000000

; URL: https://forums.adobe.com/thread/2367499
; MARI 2019

Hyper-v .. .all VMs gone after upgrade

I had an issue after a inplace upgrade of a Hyper-v 2012R2 standard to 2016 Standard.
ALl VMs is missing and there is no errors in the eventlogg..
Running the below command fixed the issues and all vms reappeared in the MMC.
Havent had the time to real figureout what it does,
beyond that it has to do with WMI settings that gone corrupt.

"The Managed Object Format (MOF) compiler parses a file containing MOF statements and
adds the classes and class instances defined in the fileto the WMI repository.
MOF files are usually automatically compiled during the installation of the systems with
which they are provided, but you can also compile MOF files
by using this tool. "

https://docs.microsoft.com/en-us/windows/desktop/wmisdk/mofcomp

FIX:
MOFCOMP %SYSTEMROOT%\System32\WindowsVirtualization.V2.mo