if PATH variable contains some error on a lot of machines, how to correct it using a SD Package ?
Example :
Some machines have these path in PATH variable :
%SystemRoott%\System32\Wbem;%SYSTEMROOOT%\System32\WindowsPowerShell\v1.0\;%SYSTEMROOOT%\System32\OpenSSH\;
SystemRoot name is incorrect (2 t or 3 o)
Client Automation - All Versions
1- Create a .bat file containing these lines :
This example is based on example above.
It replaces %SYSTEMROOOT% by %SYSTEMROOT% and %SYSTEMROOTT% by %SYSTEMROOT%
@echo off
SET POWERSHELL=%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe
echo PATH BEFORE :
%POWERSHELL% -ExecutionPolicy ByPass -Command "(Get-Item -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment').GetValue('PATH', '','DoNotExpandEnvironmentNames')"
echo.
%POWERSHELL% -ExecutionPolicy ByPass -Command "$tmppath=(Get-Item -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment').GetValue('PATH', '','DoNotExpandEnvironmentNames') -replace '%%SYSTEMROOOT%%','%%SYSTEMROOT%%' ; $tmppath=$tmppath -replace '%%SYSTEMROOTT%%','%%SYSTEMROOT%%' ; [Microsoft.Win32.Registry]::SetValue('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment','Path',$tmppath,[Microsoft.Win32.RegistryValueKind]::ExpandString)
echo.
echo PATH AFTER :
%POWERSHELL% -ExecutionPolicy ByPass -Command "(Get-Item -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment').GetValue('PATH', '','DoNotExpandEnvironmentNames')"
2- Create a SD Package for this .bat file