adminst
Goto Top

Powershell Set exclude System Proxy

Hallo zusammen

Zurzeit sind auf einem System folgendes konfiguriert als System Proxy

netsh winhttp show proxy
Proxy Server:  proxy1.domain.com:3128
Bypass List: *.domain.com;<local>

Wie kann via Remotepowershell am einfachsten den Wert auf mehren Systemen gesetzt werden
netsh winhttp show proxy
Proxy Server:  proxy1.domain.com:3128
Bypass List: *.domain.com;server2.domain2.com;<local>

Wenn als Server in
 Proxyserver: proxy1.domain.com:3128
nicht enthalten ist, soll keine Aktion durchgeführt werden und das jeweilige System ausgegeben werden.

Danke und Gruss
adminst

Content-Key: 6070693814

Url: https://administrator.de/contentid/6070693814

Printed on: April 28, 2024 at 04:04 o'clock

Mitglied: 6017814589
Solution 6017814589 Feb 21, 2023 updated at 12:46:49 (UTC)
Goto Top
$computers = "Computer1","Computer2"  
$proxy = "proxy1.domain.com:3128"  
$bypasslist = "*.domain.com;server2.domain2.com;<local>"  
Invoke-Command -ComputerName $computers -ScriptBlock {
    if ((netsh winhttp show proxy | out-string) -match [regex]::escape($using:proxy)){
        netsh winhttp set proxy $using:proxy "$using:bypasslist" | out-null     
        [pscustomobject]@{Status="Proxy-Liste gesetzt"}  
    }else{
        [pscustomobject]@{Status="Keiner/anderer Proxy"}  
    }
} | format-table PSComputername,Status -Force
Mitglied: 3063370895
3063370895 Feb 21, 2023 at 12:20:39 (UTC)
Goto Top
Zitat von @6017814589:

$computers = "Computer1","Computer2"  
$proxy = "proxy1.domain.com:3128"  
Invoke-Command -ComputerName $computers -ScriptBlock {
    if ((netsh winhttp show proxy | out-string) -notmatch [regex]::escape($proxy)){
        netsh winhttp set proxy $proxy | out-null        
        [pscustomobject]@{Status="Proxy set"}  
    }else{
        [pscustomobject]@{Status="Already configured."}  
    }
} | format-table PSComputername,Status

Da fehlt die Ausnahmeliste. Bist du's, wurstel? ;)
Mitglied: 6017814589
6017814589 Feb 21, 2023 updated at 12:23:57 (UTC)
Goto Top
Zitat von @chaot1coz:
Da fehlt die Ausnahmeliste. Bist du's, wurstel? ;)
Kann er ja hoffentlich noch selbst ergänzen 🙃, ich gehe mal davon aus das er das auch liest wen nich, pech ... Wat für ne Wurst??
Mitglied: 3063370895
3063370895 Feb 21, 2023 at 12:27:12 (UTC)
Goto Top
Zitat von @6017814589:
Wat für ne Wurst??

Dann bist du es wohl nicht face-smile sorry für die Verwirrung
Member: adminst
adminst Feb 21, 2023 at 13:00:04 (UTC)
Goto Top
Danke an alle