User Tools

Site Tools


informatique:windows:powershell

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
informatique:windows:powershell [2021/10/19 13:28] – Plein de bidules en Powershell yahikoinformatique:windows:powershell [2022/06/10 12:41] yahiko
Line 2: Line 2:
 [[informatique:windows:powershell:excel-separer-feuilles|Excel : séparer les feuilles dans des fichiers]] [[informatique:windows:powershell:excel-separer-feuilles|Excel : séparer les feuilles dans des fichiers]]
  
 +===== Autoriser l'exécution des scripts : =====
 +<codedoc code:powershell>
 +set-executionpolicy remotesigned
 +</codedoc>
 +
 +===== Lancer un script Powershell à partir d'un Batch =====
 +<codedoc code:batch>
 +Powershell.exe -executionpolicy remotesigned -File NOMDUSCRIPT.ps1
 +</codedoc>
 +
 +===== Lancer un script Powershell à partir d'un chemin UNC =====
 +Attention, c'est très sale : 
 +<codedoc code:batch>
 +Powershell.exe -NoProfile -ExecutionPolicy bypass -File "\\IP_DU_SERVEUR\OU\EST\LE\script.ps1"
 +</codedoc>
 +Source : [[https://superuser.com/questions/106360/how-to-enable-execution-of-powershell-scripts]]
  
-====== Commandes diverses ====== 
 ===== Tester la présence d'un dossier ===== ===== Tester la présence d'un dossier =====
 <codedoc code:powershell> <codedoc code:powershell>
-$dossier = "%userprofile%\paf\le\chien"+$dossier = "%userprofile%\path\le\chien" 
 if (Test-Path -Path $dossier) { if (Test-Path -Path $dossier) {
  "Le dossier $dossier !"  "Le dossier $dossier !"
Line 18: Line 34:
 <codedoc code:powershell> <codedoc code:powershell>
 $url = http://url_du_fichier $url = http://url_du_fichier
 +
 Invoke-WebRequest -Uri $url -OutFile C:\Ou\va\le\fichier\fichier.prout Invoke-WebRequest -Uri $url -OutFile C:\Ou\va\le\fichier\fichier.prout
 </codedoc> </codedoc>
Line 53: Line 70:
 } }
 Set-LocalUser -Name 'Toto' -FullName "Jean-Michel Toto" Set-LocalUser -Name 'Toto' -FullName "Jean-Michel Toto"
-</code>+</codedoc>
  
 ===== Désactiver et activer des trucs ===== ===== Désactiver et activer des trucs =====
Line 77: Line 94:
 # Installation de .NET3.5 # Installation de .NET3.5
 Enable-WindowsOptionalFeature -Online -FeatureName "NetFx3" Enable-WindowsOptionalFeature -Online -FeatureName "NetFx3"
 +</codedoc>
 +
 +===== Intégrer un poste à un domaine =====
 +<codedoc code:powershell>
 +Add-Computer -DomainName DOMAINE.LOCAL -Credential DOMAINE\administrateur -Restart -Force
 +</codedoc>
 +
 +===== Récupérer le GUID des volumes =====
 +<codedoc code:powershell>
 +GWMI -namespace root\cimv2 -class win32_volume | FL -property DriveLetter, DeviceID
 </codedoc> </codedoc>
  
  
informatique/windows/powershell.txt · Last modified: 2023/09/14 08:45 by yahiko

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki