Benutzer:MovGP0/Powershell

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen
   MovGP0        Über mich        Hilfen        Artikel        Weblinks        Literatur        Zitate        Notizen        Programmierung        MSCert        Physik      


Umgebungsvariablen

[Bearbeiten | Quelltext bearbeiten]
Umgebungsvariable setzen
# get the correct directory
$programPath = if ((${env:ProgramFiles(x86)}).Length -eq 0) 
               { 
                   ${env:ProgramFiles} 
               } 
               else 
               { 
                   ${env:ProgramFiles(x86)}
               }

# create the path to add to the path variable 
$pathToAdd = "$programPath\Java\jdk1.6.0_03\bin"

# get the current value for path 
$currentPath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path

# create the new value for path
$newPath = "$currentPath;$pathToAdd" 

# variant1: set the path with the registry provider
Set-ItemProperty -Path 'Registry::HKLM\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH Value $newPath 

# variant2: set the path with the .NET framework  
[Environment]::SetEnvironmentVariable( "Path", $newPath, [System.EnvironmentVariableTarget]::Machine )

Note: use HKCU (HKEY_CURRENT_USER) instead of HKLM (HKEY_LOCAL_MACHINE) when you want to set the variable only for the current user. That is 'User' instead of 'Machine' in the .NET variant. 

Windows-Update konfigurieren
Set-ItemProperty -path HKEY_LOCAL_MACHINE:Software\Policies\Microsoft\Windows\DeliveryOptimization -name DODownloadMode -value 3
Value Effect
0 disable
1 peers on same NAT only
2 Local Network / Private Peering (PCs in the same domain by default)
3 Internet Peering
x64 oder x32 Programm?
dumpbin /headers PROGRAMMODERDLL
PowerShell Version
$PSVersionTable.PSVersion
Desired State Configuration (DSC) commands
Find-DscResource
Import-DscResource -ModuleName "..."
Executing Program
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = "C:\Users\johann.dirry\AppData\Roaming\npm\gulp.cmd"
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = "test:build test:exec"
$pinfo.WorkingDirectory = "C:\Development\projects\sbb\RailBaggage\Web\WebApp"
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start()

$stdout = $p.StandardOutput.ReadToEnd()
$stderr = $p.StandardError.ReadToEnd()
$exitcode = $p.ExitCode

[System.Console]::WriteLine($stdout)

Text UI Libraries

[Bearbeiten | Quelltext bearbeiten]