31-08-2021

This commit is contained in:
2021-08-31 09:29:05 +02:00
parent 7d89fb0224
commit bb890cba15
28 changed files with 1888 additions and 47 deletions

View File

@@ -66,3 +66,73 @@ PUBLIC C:\Users\Public
CommonProgramFiles C:\Program Files\Common Files
```
Afficher le PATH
```powershell
> $env:Path
C:\Program Files\Parallels\Parallels Tools\Applications;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\PowerShell\7\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files (x86)\dotnet\;C:\Users\bruno\AppData\Local\Microsoft\WindowsApps;C:\Users\bruno\AppData\Local\Programs\Microsoft VS Code\bin
```
Ajouter au PATH
```
$addPath = 'C:\Folder\bin'
```
##### which:
`Get-Command <command>`
```powershell
Get-Command wsl
CommandType Name Version Source
----------- ---- ------- ------
Application wsl.exe 10.0.22... C:\WINDOWS\system32\wsl.exe
```
##### Version de Powershell:
`Get-Host`
```powershell
PS C:\Users\bruno> Get-Host
Name : ConsoleHost
Version : 7.1.4
InstanceId : c47454ef-ce56-4af8-b3e0-6b10825d6f8f
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : fr-FR
CurrentUICulture : fr-FR
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
```
`(Get-Host).Version`
```powershell
PS C:\Users\bruno> (Get-Host).Version
Major Minor Build Revision
----- ----- ----- --------
7 1 4 -1
```
`$PSVersionTable.PSVersion`
```powershell
PS C:\Users\bruno> $PSVersionTable.PSVersion
Major Minor Patch PreReleaseLabel BuildLabel
----- ----- ----- --------------- ----------
7 1 4
```

View File

@@ -1,5 +1,71 @@
# Trucs
Ouvrir Windows Terminal en 3 panneaux:
```powershell
wt -p "Debian" `; split-pane -p "PowerShell 7" `; split-pane -p "Invite de commandes"
```
Ouvrir en 3 onglets dans Windows Terminal:
```powershell
wt -p "Debian" `; new-tab -p "PowerShell 7" `; new-tab -p "Invite de commandes"
```
Palette de commande:
`Ctrl + Shift + P`
Thèmes:
https://docs.microsoft.com/en-us/windows/terminal/tutorials/powerline-setup
https://ohmyposh.dev/docs/
#### Ouvrir une nouvelle fenêtre Powershell en administrateur:
1.
```powershell
Start-Process powershell -Verb runAs
```
https://stackoverflow.com/questions/7690994/running-a-command-as-administrator-using-powershell
2.
`Win + Ctrl + Maj + 8`
Si Powershell est en 8e position dans la barre des taches (le 1er étant l'Explorateur).
3.
```powershell
# ouvre une nouvelle fenêtre de Windows Terminal en mode admin.
powershell "Start-Process -Verb RunAs cmd.exe '/c start wt.exe'"
```
4.
[gsudo](https://github.com/gerardog/gsudo)
Installation:
```powershell
choco install gsudo
winget install gsudo
```
```powershell
# Dans PowerShell ou l'invite de commande:
# donne les droits admin à la console courante
gsudo
```
```powershell
@@ -177,3 +243,28 @@ Bash <-> PowerShell:
| | | |
| | | |
#### Réinitialiser Windows Store
1ere solution:
```powershell
PS> PowerShell -ExecutionPolicy Unrestricted $manifest = (Get-AppxPackage Microsoft.WindowsStore).InstallLocation + \AppxManifest.xml ; Add-AppxPackage -DisableDevelopmentMode -Register $manifest
```
2eme solution:
```powershell
PS> sfc /scannow
```
puis reboot (fonctionne W11)
3eme solution:
```powershell
DISM /Online /Cleanup-Image /ScanHealth
```
puis reboot