├── Configure proxy on Ubuntu ├── Code │ └── Proxy.txt └── Presentation.pptx ├── Create an Active Directory IFM ├── Code │ └── IFM.ps1 └── Presentation.pptx ├── CredSSP encryption oracle remediation fix └── Presentation.pptx ├── Disable NIC DNS registration with Powershell └── Code │ └── DNS_Reg.ps1 ├── Disable Server Manager auto start └── Presentation.pptx ├── Get Global Catalogs and FSMO holders with Powershell └── commands.ps1 ├── How to install Powershell 7 on Windows Server ├── Presentation.pptx └── commands.ps1 ├── How to patch a Windows image offline with Powershell ├── Code │ ├── DISM_part.ps1 │ └── WSUS_part.ps1 └── Presentation.pptx ├── Install Hyper-V on a Windows Server 2012 VM └── commands.ps1 ├── Install Ubuntu on Windows 10 (WSL on Windows) └── commands.ps1 ├── README.md ├── Spice up your Powershell prompt Part 2 ├── Code │ └── commands.ps1 └── WindowsTerminal-settings.json └── Spice up your Powershell prompt ├── Themes └── MyTheme.psm1 ├── WindowsTerminal_WorkingFonts.txt └── commands.ps1 /Configure proxy on Ubuntu/Code/Proxy.txt: -------------------------------------------------------------------------------- 1 | ### System wide proxy 2 | #Configure proxy address 3 | export HTTP_PROXY=192.168.1.254:80 4 | #To make it permanent for your user just added to the profile script 5 | #If using authentication the full command is: export HTTP_PROXY=user:password@proxy_address:port 6 | #For HTTPS proxy servers the variable is called HTTPS_PROXY 7 | 8 | #Configure DNS server (add your DNS address) 9 | sudo nano /etc/resolv.conf 10 | #Test DNS and proxy 11 | wget http://www.w3.org 12 | 13 | 14 | ### apt and apt-get proxy 15 | #Configure proxy only for apt on ubuntu 16 | sudo touch /etc/apt/apt.conf.d/proxy.conf 17 | sudo nano /etc/apt/apt.conf.d/proxy.conf 18 | #Add line: 19 | Acquire::http::Proxy "http://192.168.1.254:80"; 20 | #If using authentication the full line is: 21 | Acquire::http::Proxy "http://user:password@proxy_address:port"; 22 | #For HTTPS proxy servers just replace http with https 23 | #Test that packages can be downloaded 24 | sudo apt install isc-dhcp-server 25 | 26 | 27 | ### proxy for curl 28 | #Access a site with curl 29 | curl -I https://www.google.com -x 192.168.1.254:80 30 | #For proxy with authentication you can use the syntax: -x 'http://user:password@proxy_address:port' 31 | #Replace http with https in case this is needed 32 | 33 | -------------------------------------------------------------------------------- /Configure proxy on Ubuntu/Presentation.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itknowledge4/QuickTips/58a7803e2c00bf0d1a7d414558518749a115d5bf/Configure proxy on Ubuntu/Presentation.pptx -------------------------------------------------------------------------------- /Create an Active Directory IFM/Code/IFM.ps1: -------------------------------------------------------------------------------- 1 | #To create an IFM in interactive mode 2 | ntdsutil 3 | activate instance ntds 4 | ifm 5 | create sysvol full 6 | #Then copy the folde to the new server that will be promoted 7 | #To see more options just type ? 8 | 9 | #To create an IFM in one command 10 | ntdsutil "activate instance ntds" ifm "create sysvol Full " q q q -------------------------------------------------------------------------------- /Create an Active Directory IFM/Presentation.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itknowledge4/QuickTips/58a7803e2c00bf0d1a7d414558518749a115d5bf/Create an Active Directory IFM/Presentation.pptx -------------------------------------------------------------------------------- /CredSSP encryption oracle remediation fix/Presentation.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itknowledge4/QuickTips/58a7803e2c00bf0d1a7d414558518749a115d5bf/CredSSP encryption oracle remediation fix/Presentation.pptx -------------------------------------------------------------------------------- /Disable NIC DNS registration with Powershell/Code/DNS_Reg.ps1: -------------------------------------------------------------------------------- 1 | #Disable DNS registration for a net adapter 2 | Set-DnsClient -InterfaceIndex 12 -RegisterThisConnectionsAddress 0 3 | #Enable DNS registration for a net adapter 4 | Set-DnsClient -InterfaceIndex 12 -RegisterThisConnectionsAddress 1 -------------------------------------------------------------------------------- /Disable Server Manager auto start/Presentation.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itknowledge4/QuickTips/58a7803e2c00bf0d1a7d414558518749a115d5bf/Disable Server Manager auto start/Presentation.pptx -------------------------------------------------------------------------------- /Get Global Catalogs and FSMO holders with Powershell/commands.ps1: -------------------------------------------------------------------------------- 1 | #Get a list of all Domain Controllers 2 | Get-ADDomainController -Filter * | Select-Object Name 3 | #Get a list of all Domain Controllers that are Global Catalogs 4 | Get-ADDomainController -Filter {IsGlobalCatalog -eq $True} 5 | #Get a list of Domain Controllers that hold at least a FSMO role 6 | Get-ADDomainController -Filter {OperationMasterRoles -ne ''} 7 | 8 | #Get a list of the holders for domain level FSMO roles 9 | Get-ADDomain | Select-Object InfrastructureMaster,PDCEmulator,RIDMaster 10 | #Get a list of forest level FSMO roles 11 | Get-ADForest | Select-Object DomainNamingMaster,SchemaMaster 12 | #Get all global catalogs from the forest 13 | Get-ADForest | Select-Object -ExpandProperty GlobalCatalogs -------------------------------------------------------------------------------- /How to install Powershell 7 on Windows Server/Presentation.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itknowledge4/QuickTips/58a7803e2c00bf0d1a7d414558518749a115d5bf/How to install Powershell 7 on Windows Server/Presentation.pptx -------------------------------------------------------------------------------- /How to install Powershell 7 on Windows Server/commands.ps1: -------------------------------------------------------------------------------- 1 | #Install the C Runtime 2 | Start-Process wusa.exe -ArgumentList "C:\Tools\WindowsUCRT\Windows8-RT-KB3118401-x64.msu",'/quiet','/norestart' -Wait 3 | #Install WMF 5.1 4 | Start-Process wusa.exe -ArgumentList "C:\Tools\W2K12-KB3191565-x64.msu",'/quiet','/norestart' -Wait 5 | #A restart is needed after WMF 5.1 has been installed 6 | Restart-Computer 7 | #Install Powershell 7 8 | Start-Process msiexec.exe -ArgumentList "/package C:\Tools\PowerShell-7.0.0-win-x64.msi","/quiet","ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 ENABLE_PSREMOTING=1 REGISTER_MANIFEST=1" -Wait 9 | #Disable Update Notification 10 | $Env:POWERSHELL_UPDATECHECK = 'Off' 11 | 12 | #Test remoting 13 | Enter-PSSession -ComputerName DC02 -ConfigurationName PowerShell.7.0.0 -------------------------------------------------------------------------------- /How to patch a Windows image offline with Powershell/Code/DISM_part.ps1: -------------------------------------------------------------------------------- 1 | #Create folder where the image will be mounted 2 | mkdir C:\mount 3 | $MountDir='C:\mount' 4 | 5 | Get-WindowsImage -ImagePath 'C:\install.wim' 6 | Mount-WindowsImage -Path $mountdir -ImagePath C:\install.wim -Index 1 7 | foreach($upd in $UpdateFiles){ Add-WindowsPackage -PackagePath $upd -Path $mountdir } 8 | Dismount-WindowsImage -Path $mountdir -Save 9 | 10 | 11 | -------------------------------------------------------------------------------- /How to patch a Windows image offline with Powershell/Code/WSUS_part.ps1: -------------------------------------------------------------------------------- 1 | #Change for your environment 2 | $WSUSServer='WSUS01' 3 | $TargetOS='Windows Server 2016' 4 | 5 | #If the server on which you run the script does not have WSUS tools installed run: 6 | Install-WindowsFeature UpdateServices-API 7 | 8 | mkdir C:\Updates 9 | $LocalUpdates='C:\Updates' 10 | 11 | $WSUS=Get-WsusServer -Name $WSUSServer -PortNumber 8530 12 | $AllUpdates=$WSUS.GetUpdates() 13 | 14 | $WSUSUpdates=$AllUpdates | Where-Object {$TargetOS -in $_.ProductTitles -and $_.IsApproved -eq $true -and $_.IsSuperseded -eq $false} 15 | 16 | foreach($Update in $WSUSUpdates) 17 | { 18 | $CabUris=$Update.GetInstallableItems() | Select-Object -ExpandProperty Files | Where-Object {$_.Type -eq 'SelfContained'} | Select-Object -ExpandProperty FileUri | Select-Object -ExpandProperty AbsoluteUri 19 | foreach($CabUri in $CabUris) 20 | { 21 | $CabName=$CabUri | Split-Path -Leaf 22 | $CabUriPath=$CabUri.Replace('/','\').Replace('http:','').Replace(':8530','\C$').Replace('Content','WSUS\WsusContent') 23 | Copy-Item $CabUriPath $LocalUpdates 24 | } 25 | } 26 | 27 | $UpdateFiles=Get-ChildItem $LocalUpdates | Select-Object -ExpandProperty FullName -------------------------------------------------------------------------------- /How to patch a Windows image offline with Powershell/Presentation.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itknowledge4/QuickTips/58a7803e2c00bf0d1a7d414558518749a115d5bf/How to patch a Windows image offline with Powershell/Presentation.pptx -------------------------------------------------------------------------------- /Install Hyper-V on a Windows Server 2012 VM/commands.ps1: -------------------------------------------------------------------------------- 1 | #Important: You can install the Hyper-V role and management tools on a 2012/2012R2 VM but cannot run virtual machines because it does not have guest support for nested virtualization (if the VM is on Hyper-V) 2 | 3 | Enable-WindowsOptionalFeature –Online -FeatureName Microsoft-Hyper-V –All -NoRestart 4 | Install-WindowsFeature RSAT-Hyper-V-Tools -IncludeAllSubFeature 5 | Restart-Computer -------------------------------------------------------------------------------- /Install Ubuntu on Windows 10 (WSL on Windows)/commands.ps1: -------------------------------------------------------------------------------- 1 | #This file contains commands and instructions for installing Linux distributions on Windows for through WSL 2 | 3 | # 1. First we need to enable the WSL optional feature and restart the computer 4 | Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart 5 | Restart-Computer 6 | 7 | # 2. Create a folder where the Linux distribution will be placed and executed from 8 | New-Item C:\Distros -ItemType Directory 9 | Set-Location C:\Distros 10 | 11 | # 3. Use one of the commands below to download the distribution of your choice (I will go with the first one) 12 | # Ubuntu 18.04 13 | Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile .\Ubuntu.appx -UseBasicParsing 14 | # Ubuntu 16.04 15 | Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1604 -OutFile .\Ubuntu.appx -UseBasicParsing 16 | # Debian GNU Linux 17 | Invoke-WebRequest -Uri https://aka.ms/wsl-debian-gnulinux -OutFile .\Debian.appx -UseBasicParsing 18 | # Kali Linux 19 | Invoke-WebRequest -Uri https://aka.ms/wsl-kali-linux -OutFile .\Kali.appx -UseBasicParsing 20 | # OpenSUSE 21 | Invoke-WebRequest -Uri https://aka.ms/wsl-opensuse-42 -OutFile .\SUSE.appx -UseBasicParsing 22 | # SLES 23 | Invoke-WebRequest -Uri https://aka.ms/wsl-sles-12 -OutFile .\SLES.appx -UseBasicParsing 24 | 25 | # 4. Rename and extract the distro file 26 | Rename-Item .\Ubuntu.appx .\Ubuntu.zip 27 | Expand-Archive .\Ubuntu.zip 28 | 29 | # 5. Clean up 30 | Remove-Item ".\Ubuntu.*" 31 | 32 | # 6. Install the Linux distribution 33 | # Make sure you do not forget the passwor that you will enter at the prompt as that is your root password 34 | Set-Location .\Ubuntu 35 | .\ubuntu1804.exe 36 | 37 | #To run the WSL shell after the installation just run one of the following 38 | wsl.exe 39 | bash.exe 40 | ubuntu1804.exe #from the distro install directory -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QuickTips 2 | Repository for code and other learning materials for the AboutIT QuickTip type videos
3 | 4 | ## Video list 5 | This is a list of all videos in the QuickTips category. They are placed in reverse chronological order so the first video in this list will always be the newest.
6 | 7 | [Install WSL on Windows 11](https://youtu.be/BieiUlNSm_Y)
8 | [Configure proxy on Ubuntu](https://youtu.be/OJLGGaJPWM8)
9 | [How to patch a Windows image offline with Powershell](https://youtu.be/WJovyceBf7g)
10 | [Spice up your Powershell prompt Part 2](https://youtu.be/gslN7Q_3P3I)
11 | [Create an Active Directory IFM](https://youtu.be/_C8Hilr_Jws)
12 | [Disable NIC DNS registration with Powershell](https://youtu.be/_g-Y1ClIMMk)
13 | [CredSSP encryption oracle remediation fix](https://youtu.be/kK-2uH-8axU)
14 | [How to install Powershell 7 on Windows Server](https://youtu.be/073p54BcyLA)
15 | [Extend Windows Server Evaluation time to avoid automatic Shut Down](https://youtu.be/N5AATvnUihM)
16 | [Install Hyper-V on a Windows Server 2012 VM](https://youtu.be/er8ocGGh6mk)
17 | [Spice up your Powershell prompt](https://youtu.be/3Q5tOjdqysg)
18 | [Get Globab Catalogs and FSMO holders with Powershell](https://youtu.be/5Lw-qbIDhzw)
19 | [Disable Server Manager auto start](https://youtu.be/iyFUzt1S0Fs)
20 | [Install Ubuntu on Windows 10 (WSL on Windows)](https://youtu.be/XDvt4dIN-Mw) -------------------------------------------------------------------------------- /Spice up your Powershell prompt Part 2/Code/commands.ps1: -------------------------------------------------------------------------------- 1 | #Set a new execution policy 2 | Set-ExecutionPolicy Unrestricted -Force 3 | 4 | #Navigate to home folder 5 | cd $HOME 6 | 7 | #Install modules 8 | Install-Module oh-my-posh -Force 9 | #If you use Git then this one will be useful 10 | Install-Module posh-git -Force 11 | 12 | #you can also get these modules from GitHub and install them manually 13 | #oh-my-posh - https://github.com/JanDeDobbeleer/oh-my-posh 14 | #posh-git - https://github.com/dahlbyk/posh-git 15 | 16 | #Get and install some cool fonts 17 | #Choose from different fonts here: https://www.nerdfonts.com/font-downloads 18 | Invoke-WebRequest -Uri 'https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/DejaVuSansMono.zip' -OutFile .\DejaVuSansMono.zip 19 | Expand-Archive .\DejaVuSansMono.zip 20 | #Get a module that contains a script to install fonts with Powershell 21 | #The module can be downloaded manually from: https://www.powershellgallery.com/packages/PSWinGlue/0.5.5 22 | Invoke-WebRequest -Uri 'https://github.com/ralish/PSWinGlue/archive/refs/tags/v0.5.5.zip' -OutFile .\PSWinGlue.zip 23 | Expand-Archive .\PSWinGlue.zip 24 | Move-Item .\PSWinGlue\PSWinGlue-0.5.5\Scripts\Install-Font.ps1 .\ 25 | #Install the font 26 | .\Install-Font.ps1 -Path '.\DejaVuSansMono\DejaVu Sans Mono Nerd Font Complete Mono Windows Compatible.ttf' 27 | 28 | #Clean up after install is done 29 | Remove-Item .\DejaVuSansMono.zip 30 | Remove-Item .\PSWinGlue* -Recurse 31 | 32 | #revert to the old execution policy 33 | Set-ExecutionPolicy $Policy -Force 34 | 35 | #Set one of the newly installed font in your Powershell console 36 | 37 | #Take it for a spin 38 | Import-Module oh-my-posh 39 | #If you use Git 40 | Import-Module posh-git 41 | Set-PoshPrompt agnoster 42 | #See available themes; new themes can be placed in the module directory in Themes 43 | Get-PoshThemes 44 | 45 | #To always start Powershell with these settings add commands to your PS profile 46 | #Run from Powershell.exe and not Powershell ISE 47 | if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force } 48 | notepad $PROFILE 49 | #Add the import commands and the set-prompt command in the file 50 | #Close PS and open it again 51 | 52 | #Test out git 53 | mkdir git 54 | cd git 55 | git init -------------------------------------------------------------------------------- /Spice up your Powershell prompt Part 2/WindowsTerminal-settings.json: -------------------------------------------------------------------------------- 1 | // This file was initially generated by Windows Terminal 1.6.10571.0 2 | // It should still be usable in newer versions, but newer versions might have additional 3 | // settings, help text, or changes that you will not see unless you clear this file 4 | // and let us generate a new one for you. 5 | 6 | // To view the default settings, hold "alt" while clicking on the "Settings" button. 7 | // For documentation on these settings, see: https://aka.ms/terminal-documentation 8 | { 9 | "$schema": "https://aka.ms/terminal-profiles-schema", 10 | 11 | "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", 12 | 13 | // You can add more global application settings here. 14 | // To learn more about global settings, visit https://aka.ms/terminal-global-settings 15 | 16 | // If enabled, selections are automatically copied to your clipboard. 17 | "copyOnSelect": false, 18 | 19 | // If enabled, formatted data is also copied to your clipboard 20 | "copyFormatting": false, 21 | 22 | // A profile specifies a command to execute paired with information about how it should look and feel. 23 | // Each one of them will appear in the 'New Tab' dropdown, 24 | // and can be invoked from the commandline with `wt.exe -p xxx` 25 | // To learn more about profiles, visit https://aka.ms/terminal-profile-settings 26 | "profiles": 27 | { 28 | "defaults": 29 | { 30 | // Put settings here that you want to apply to all profiles. 31 | }, 32 | "list": 33 | [ 34 | { 35 | // Make changes here to the powershell.exe profile. 36 | "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", 37 | "name": "Windows PowerShell", 38 | "commandline": "powershell.exe", 39 | "hidden": false, 40 | "fontSize": 13, 41 | "cursorShape": "emptyBox", 42 | "colorScheme": "Campbell Powershell", 43 | "useAcrylic": true, 44 | "acrylicOpacity": 0.93, 45 | "fontFace": "DejaVuSansMono NF" 46 | }, 47 | { 48 | // Make changes here to the cmd.exe profile. 49 | "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", 50 | "name": "Command Prompt", 51 | "commandline": "cmd.exe", 52 | "hidden": false 53 | }, 54 | { 55 | "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}", 56 | "hidden": false, 57 | "name": "Azure Cloud Shell", 58 | "source": "Windows.Terminal.Azure" 59 | } 60 | ] 61 | }, 62 | 63 | // Add custom color schemes to this array. 64 | // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes 65 | "schemes": [], 66 | 67 | // Add custom actions and keybindings to this array. 68 | // To unbind a key combination from your defaults.json, set the command to "unbound". 69 | // To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings 70 | "actions": 71 | [ 72 | // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json. 73 | // These two lines additionally bind them to Ctrl+C and Ctrl+V. 74 | // To learn more about selection, visit https://aka.ms/terminal-selection 75 | { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" }, 76 | { "command": "paste", "keys": "ctrl+v" }, 77 | 78 | // Press Ctrl+Shift+F to open the search box 79 | { "command": "find", "keys": "ctrl+shift+f" }, 80 | 81 | // Press Alt+Shift+D to open a new pane. 82 | // - "split": "auto" makes this pane open in the direction that provides the most surface area. 83 | // - "splitMode": "duplicate" makes the new pane use the focused pane's profile. 84 | // To learn more about panes, visit https://aka.ms/terminal-panes 85 | { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" } 86 | ] 87 | } 88 | -------------------------------------------------------------------------------- /Spice up your Powershell prompt/Themes/MyTheme.psm1: -------------------------------------------------------------------------------- 1 | #requires -Version 2 -Modules posh-git 2 | 3 | #Use with Inconsolata for Powerline font for best experience 4 | function Write-Theme { 5 | 6 | param( 7 | [bool] 8 | $lastCommandFailed, 9 | [string] 10 | $with 11 | ) 12 | 13 | $lastColor = $sl.Colors.PromptBackgroundColor 14 | 15 | $prompt = Write-Prompt -Object $sl.PromptSymbols.StartSymbol -ForegroundColor $sl.Colors.SessionInfoForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor 16 | 17 | #check the last command state and indicate if failed 18 | If ($lastCommandFailed) { 19 | $prompt += Write-Prompt -Object "$($sl.PromptSymbols.FailedCommandSymbol) " -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor 20 | } 21 | 22 | #check for elevated prompt 23 | If (Test-Administrator) { 24 | $prompt += Write-Prompt -Object "$($sl.PromptSymbols.ElevatedSymbol) " -ForegroundColor $sl.Colors.AdminIconForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor 25 | } 26 | 27 | $user = [System.Environment]::UserName 28 | $computer = [System.Environment]::MachineName 29 | if (Test-NotDefaultUser($user)) { 30 | $prompt += Write-Prompt -Object "$user@$computer " -ForegroundColor $sl.Colors.SessionInfoForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor 31 | } 32 | 33 | if (Test-VirtualEnv) { 34 | $prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor 35 | $prompt += Write-Prompt -Object "$($sl.PromptSymbols.VirtualEnvSymbol) $(Get-VirtualEnvName) " -ForegroundColor $sl.Colors.VirtualEnvForegroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor 36 | $prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.VirtualEnvBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor 37 | } 38 | else { 39 | $prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.PromptHighlightColor 40 | } 41 | 42 | $status = Get-VCSStatus 43 | 44 | # Writes the drive portion 45 | $path = (Get-FullPath -dir $pwd).Replace('\', ' ' + [char]::ConvertFromUtf32(0xE0B1) + ' ') + ' ' 46 | $prompt += Write-Prompt -Object $path -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor 47 | if(!$Status) 48 | { 49 | $prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $sl.Colors.PromptBackgroundColor 50 | } 51 | 52 | if ($status) { 53 | $themeInfo = Get-VcsInfo -status ($status) 54 | $lastColor = $themeInfo.BackgroundColor 55 | $prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $sl.Colors.PromptBackgroundColor -BackgroundColor $lastColor 56 | $prompt += Write-Prompt -Object " $($themeInfo.VcInfo) " -BackgroundColor $lastColor -ForegroundColor $sl.Colors.GitForegroundColor 57 | $prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $lastColor 58 | } 59 | 60 | $timeStamp = Get-Date -UFormat %R 61 | $timestamp = "[$timeStamp]" 62 | 63 | $prompt += Set-CursorForRightBlockWrite -textLength ($timestamp.Length + 1) 64 | $prompt += Write-Prompt $timeStamp -ForegroundColor $sl.Colors.PromptForegroundColor 65 | 66 | $prompt += Set-Newline 67 | 68 | if ($with) { 69 | $prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $lastColor -BackgroundColor $sl.Colors.WithBackgroundColor 70 | $prompt += Write-Prompt -Object " $($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor 71 | $lastColor = $sl.Colors.WithBackgroundColor 72 | } 73 | 74 | # Writes the postfix to the prompt 75 | $prompt += Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $sl.Colors.PromptForegroundColor 76 | $prompt += ' ' 77 | $prompt 78 | } 79 | 80 | $sl = $global:ThemeSettings #local settings 81 | $sl.PromptSymbols.StartSymbol = '' 82 | $sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x276F) 83 | $sl.PromptSymbols.SegmentForwardSymbol = [char]::ConvertFromUtf32(0xE0B0) 84 | $sl.Colors.SessionInfoBackgroundColor = [ConsoleColor]::DarkGray 85 | $sl.Colors.PromptForegroundColor = [ConsoleColor]::White 86 | $sl.Colors.PromptSymbolColor = [ConsoleColor]::White 87 | $sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue 88 | $sl.Colors.GitForegroundColor = [ConsoleColor]::White 89 | $sl.Colors.GitLocalChangesColor = [ConsoleColor]::DarkRed 90 | $sl.Colors.WithForegroundColor = [ConsoleColor]::White 91 | $sl.Colors.WithBackgroundColor = [ConsoleColor]::DarkRed 92 | $sl.Colors.VirtualEnvBackgroundColor = [System.ConsoleColor]::Red 93 | $sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::White -------------------------------------------------------------------------------- /Spice up your Powershell prompt/WindowsTerminal_WorkingFonts.txt: -------------------------------------------------------------------------------- 1 | Space Mono for Powerline 2 | Roboto Mono for Powerline 3 | Noto Mono for Powerline 4 | Monofur for Powerline 5 | Source Code Pro for Powerline 6 | Inconsolata-g for Powerline 7 | Inconsolata-dz for Powerline 8 | Inconsolata for Powerline 9 | Hack 10 | Go Mono for Powerline 11 | Fira Mono for Powerline 12 | DejaVu Sans Mono for Powerline -------------------------------------------------------------------------------- /Spice up your Powershell prompt/commands.ps1: -------------------------------------------------------------------------------- 1 | #Install modules 2 | Install-Module oh-my-posh 3 | Install-Module posh-git #needed if you use Git (you will also need the Git client) 4 | 5 | #you can also get these modules from GitHub and install them manually 6 | #oh-my-posh - https://github.com/JanDeDobbeleer/oh-my-posh 7 | #posh-git - https://github.com/dahlbyk/posh-git 8 | 9 | #Get and install some cool fonts 10 | Invoke-WebRequest -Uri 'https://github.com/powerline/fonts/archive/master.zip' -OutFile .\powerlinefonts.zip 11 | Expand-Archive .\powerlinefonts.zip 12 | .\powerlinefonts\fonts-master\install.ps1 13 | #Clean up after install is done 14 | Remove-Item .\powerlinefonts.zip 15 | Remove-Item .\powerlinefonts -Recurse 16 | 17 | #Set one of the newly installed fonts in your Powershell console 18 | #For powershell.exe I use DejaVu Sans Mono for Powerline 19 | #For powershell in Windows Terminal I use Inconsolata for Powerline 20 | #Note: not all fonts work in Windows Terminal for now; see list in gitHub repo 21 | 22 | #Take it for a spin 23 | Import-Module oh-my-posh 24 | Import-Module posh-git #If you use git 25 | Set-Theme Agnoster 26 | #See available themes; new themes can be placed in the directory 27 | Get-Theme 28 | Set-Theme MyTheme 29 | 30 | #To always start Powershell with these settings add commands to your PS profile 31 | if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force } 32 | notepad $PROFILE 33 | #Add the 3 commands (or others) to the file and save 34 | #Close PS and open it again --------------------------------------------------------------------------------