I am trying to use an HTTP proxy I purchased from TorGuard with PowerShell. I am able to successfully connect to the proxy server however it returns a Cache Access Denied Error message. My script is:
$url = "http://www.foo.org/"
$request = Invoke-WebRequest -Uri $url `
-Proxy "http://web.proxy.torguard.org:6060" -ProxyCredential $myCreds
The complete error message returned is:
The following error was encountered while trying to retrieve the URL: http://www.foo.org/
Cache Access Denied.
Sorry, you are not currently allowed to request http://www.foo.org/ from this cache until you have authenticated yourself.
Please contact the cache administrator if you have difficulties authenticating yourself.
Generated Sat, 05 Sep 2015 16:07:20 GMT by 91.233.116.119 (squid/3.1.23)
The same error message is returned regardless of the value of $url.
This is what TorGuard support said:
It sounds like it’s not submitting the form.
Am I missing a parameter in my Invoke-WebRequest?
Related
Im using powershell to connect to azure ad and what I need is to get a list of the policies that were configured.
First, I used Connect-azuread to get into my tenant, and when I tryed to use Get-AzureADPolicy, I'm having this error:
Get-AzureADPolicy: Error occurred while executing GetPolicies Code: InvalidAuthenticationToken Message: Access token validation failure. Invalid audience. InnerError:
DateTimeStamp: Wed, 16 Feb 2022 20:36:13 GMT HttpStatusCode: Unauthorized HttpStatusDescription: Unauthorized HttpResponseStatus: Completed
any ideas of what could I been doing wrong?
Thanks
I have tested in my environment. I was able to get the list of policies successfully.
Try using AzureADPreview latest module
Uninstall-Module AzureAD
Install-Module AzureADPreview
Import-Module AzureADPreview
Now, use cmdlet “Connect-AzureAD” with credentials and “Get-AzureADPolicy” to display the list of policies.
If still the error remains, please check if you have permissions and granted consent for the same.
Try with "Connect-AzureAD -AzureEnvironmentName AzureUSGovernment"
Reference:
Get-AzureADDirectorySetting - Authintication problems - Microsoft Q&A
after running this command
$cred = get-credential
Connect-NsxServer -vCenterServer MyVsphereServer -Credential $cred
I get this error
Connection to NSX server 10.X.X.X failed : Invoke-NsxRestMethod : The NSX API response received indicates a failure. 403 : Forbidden : Response Body:
At C:\Program Files\WindowsPowerShell\Modules\PowerNSX\3.0.1174\PowerNSX.psm1:4939 char:13
+ Throw "Connection to NSX server $NsxServer failed : $_"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Connection to N...Response Body: :String) [], RuntimeException
+ FullyQualifiedErrorId : Connection to NSX server 10.X.X.X failed : Invoke-NsxRestMethod : The NSX API response received indicates a failure. 403 : Forbidden : Respons
e Body:
I see this in the error, but have never set this before either
The variable '$defaultNSXConnection' cannot be retrieved because it has not been set.
The PowerNSX module comment says:
Invoke-NsxWebRequest uses either a specified connection object as returned
by Connect-NsxServer, or the $DefaultNsxConnection global variable if
defined to construct a REST api call to the NSX API.
My account permissions can't be the issue. I can log into the NSX gui and have enterprise admin creds. I can also successfully log into Vsphere with powercli module and run cmdlets against it. It's specifically when I try to connect to NSX that I get an error. Lost at this point. Not sure why it won't work. Tried by IP and FQDN. the -vcenterserver parameter is prefered according to their documenation, and I do see Green text response directing to the correct nsx manager IP address. Everything looks right, but clearly something isn't.
powernsx apparently REQUIRES you to use the administrator#vsphere.local account to use it, regardless if your other admin account can make any API call supported by NSX with native API calls.
Didn't see that in the powernsx documentation. If it's not just an oversite on my part, that really should be front and center in their docs.
We have MS AD authenticated accounts that we use with vSphere. I use PowerNSX with my own credential and no, I do not have to use administrator#vsphere.local. The only way I have success is if I am careful to put the domain of the account in all-caps, Kerberos style. When I give the credential, the ONLY format that works for me is "username#MY.DOMAIN.COM" it is extremely case sensitive.
vSphere 6.7, NSX 6.4.8, PowerNSX 3.0.1174
I am trying to retrieve the Usage (report) data from Microsoft Graph using PowerShell but I'm getting the following exception:
System.Net.WebException: The underlying connection was closed:
An unexpected error occurred on a send.
---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
It looks like server is terminating the connection abruptly.
Here are the commands that I am using through PowerShell
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
$headers = #{Authorization = 'Bearer ' + $AT.AccessToken; ContentType='application/json'}
$result=Invoke-RestMethod -Method GET -Uri "https://graph.microsoft.com/v1.0/reports/getOffice365ActiveUserDetail(period='D90')?$format=text/csv" -Headers $headers
This is happening intermittently, regardless of setting Tls12. I have analyzed the packets through Wireshark and it looks like TLS handshake was completed correctly.
Version: TLS 1.2 (0x0303)
Cipher Suite: TLS_RSA_WITH_AES_256_GCM_SHA384 (0x009d)
I also see that Change Cipher Spec was communicated by client and server.
TLSv1.2 Record Layer: Change Cipher Spec Protocol: Change Cipher Spec
It is important to note that I am able to get the Users and SubscribedSkus correctly, so I can't conclude that this is happening because of the TLS issues. It's only the /reports endpoint which is causing the problem.
Any insight will be helpful to address this problem.
Is it possible that Usage data is large and leads to connection termination?
This endpoint doesn't return the data directly, it returns a 302 redirect to a CSV file to download. You'll want to sepcifiy an OutFile to save the file to:
$uri = "https://graph.microsoft.com/v1.0/reports/getOffice365ActiveUserDetail(period='D90')?$format=text/csv"
Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -OutFile report.csv
I'm trying to deploy a SAILS app & a VUE app on heroku with a custom domain. I'm currently facing with something that seems to be a CORS issue, but I do not understand this one.
Problem
When I send a GET request to my backend in stage mode, (with postman or my frontend-app) I get an error message :
"... blocking Cross-Origin Request : the "same origin" policy does not
allow access to the resource located at
https://app-frontend.herokuapp.com/api/v1/account/user-controller
...".
The HTML response is :
Status 503 →Service Unavailable
Cache-Control →no-cache, no-store
Connection →keep-alive
Content-Length →511
Content-Type →text/html; charset=utf-8
Date →Tue, 24 Jul 2018 08:17:13 GMT
Server →Cowboy
And my sails console gives me this info :
Redirecting GET request from 'undefined.' subdomain...
But with POST requests, I don't face to this problem and my route is well defined as it works in dev mode.
Did you try setting csrf: false in the config/security.js? It shouldn't affect GET requests, but the key to your problem might be somewhere there.
I am trying to reproduce some HTTP requests I launched with the Postman Chrome extension on a PowerShell script.
The goal of my request is to recieve a ticket by logging in to a CAS server.
I wrote the following PowerShell (I used [variable] notation for anonymisation purposes) :
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} ;
$postParams = #{username='[username]';password='[password]'}
Invoke-WebRequest -Uri https://[host]:[port]/cas/v1/tickets/ -Method POST -
Body $postParams'
But the Tomcat server answers with a HTTP 404 error whereas the same request on Postman provides me with the ticket and works perfectly.
404 indicates that something is wrong with the URL you are sending the request. You could use fiddler to trace the request and check the URL