Proxy setting for powershell connecting to outlook.office365 -
i'm working on powershell script connect outlook office365(exchange online) follows:
$session = new-pssession -configurationname microsoft.exchange -connectionuri "https://outlook.office365.com/powershell-liveid/" -credential $credential -authentication basic -allowredirection
now problem want connect via proxy server authentication, did following
$proxy = new-object system.net.webproxy "http://myproxy:80" $proxy.credentials = $cred [system.net.webrequest]::defaultwebproxy = $proxy $session = new-pssession -configurationname microsoft.exchange -connectionuri "https://outlook.office365.com/powershell-liveid/" -credential $credential -authentication basic -allowredirection
but doesn't connect via proxy set. did following:
$proxy = new-object system.net.webproxy "http://myproxy:80" $proxy.credentials = $cred [system.net.webrequest]::defaultwebproxy = $proxy $sessionoption = new-pssessionoption -proxyaccesstype ieconfig $session = new-pssession -configurationname microsoft.exchange -connectionuri "https://outlook.office365.com/powershell-liveid/" -credential $credential -authentication basic -allowredirection -sessionoption $sessionoption
but still doesn't pass through proxy.
i tried use netsh winhttp set proxy "myproxy:80" , passed through proxy server seems doesn't have authentication.
is there way explicitly set proxy new-pssession cmdlet? note: don't want set proxy setting on ie, want explicitly set proxy per session.
thanks in advance.
did tried following:
1.) set proxy via netsh
2.) inside powershell approach use:
$webclient=new-object system.net.webclient $creds=get-credential $webclient.proxy.credentials=$creds
Comments
Post a Comment