Giter Club home page Giter Club logo

Comments (9)

snazy2000 avatar snazy2000 commented on July 20, 2024

If your run it without the where-object does it return anything?

from snipeitps.

dilpatel45 avatar dilpatel45 commented on July 20, 2024

I've tried without the where-object and I get this error message:
At line:1 char:1135

  • ... WM2Il0qU6hCHDn3Gpt7szK7ziQfgYv-WI_rVXLSX2gIFk" | {$_.name -eq "MIS" }
  •                                                  ~~~~~~~~~~~~~~~~~~~~
    

Expressions are only allowed as the first element of a pipeline.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpressionsMustBeFirstInPipeline

I ran the whole command with verbose and this is what i get:

VERBOSE: [ConvertTo-GetParameter] Making HTTP get parameter string out of a hashtable
VERBOSE: [Invoke-SnipeitMethod] Invoking method Get to URI
https://snipe.maderacoe.org/api/v1/hardware?offset=0&sort=created_at&limit=50&order=desc
VERBOSE: GET https://snipe.maderacoe.org/api/v1/hardware?offset=0&sort=created_at&limit=50&order=desc with 0-byte
payload
VERBOSE: [Invoke-SnipeitMethod] Failed to get an answer from the server
VERBOSE: [Invoke-SnipeitMethod] No Web result object was returned from. This is unusual!
VERBOSE: [Invoke-SnipeitMethod] Function ended

from snipeitps.

snazy2000 avatar snazy2000 commented on July 20, 2024

The log suggests it cannot connect to the server

from snipeitps.

dilpatel45 avatar dilpatel45 commented on July 20, 2024

That's strange, i've tried the IP address and hostname and I get the same error message. I've also turned off the firewall on Snipe-IT server. I'm missing something. Any suggestions?

from snipeitps.

snazy2000 avatar snazy2000 commented on July 20, 2024

@dilpatel45 are you still having issues with this? if so can you try running

Get-Asset -url "https://name.org" -apikey "keystringinhere" -verbose

from snipeitps.

dilpatel45 avatar dilpatel45 commented on July 20, 2024

@snazy2000 yes, i'm still having issues. Is there something in snipe I need to change or alter or verify?

PS C:\Windows\system32> Get-Asset -url "https://snipe.domain.org" -apikey "KEY(actual key)" -verbose

VERBOSE: [ConvertTo-GetParameter] Making HTTP get parameter string out of a hashtable
VERBOSE: [Invoke-SnipeitMethod] Invoking method Get to URI
https://snipe.maderacoe.org/api/v1/hardware?offset=0&sort=created_at&limit=50&order=desc
VERBOSE: GET https://snipe.maderacoe.org/api/v1/hardware?offset=0&sort=created_at&limit=50&order=desc with 0-byte
payload
VERBOSE: [Invoke-SnipeitMethod] Failed to get an answer from the server
VERBOSE: [Invoke-SnipeitMethod] No Web result object was returned from. This is unusual!
VERBOSE: [Invoke-SnipeitMethod] Function ended
PS C:\Windows\system32>

from snipeitps.

snazy2000 avatar snazy2000 commented on July 20, 2024

Can you access the url from the machine your running the script? Do you have anything on your network that blocks powershell making requests like your AV or firewall.

Is the key 100% correct? May be worth trying to access it via application like postman to make sure you can access the API etc

from snipeitps.

dilpatel45 avatar dilpatel45 commented on July 20, 2024

Yes, I've verified i can resolve the hostname. I've even tried turning off the firewall internally for testing. Same issue. Yes, i've generated the key multiple times but same error message. I'll check with postman and update again.

from snipeitps.

dilpatel45 avatar dilpatel45 commented on July 20, 2024

Got it working now, thanks. I was using a Self-Signed certificate to access snipe. I found this command online to bypass and allow self-signed certificates:

if (-not("dummy" -as [type])) {
    add-type -TypeDefinition @"
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

public static class Dummy {
    public static bool ReturnTrue(object sender,
        X509Certificate certificate,
        X509Chain chain,
        SslPolicyErrors sslPolicyErrors) { return true; }
    public static RemoteCertificateValidationCallback GetDelegate() {
        return new RemoteCertificateValidationCallback(Dummy.ReturnTrue);
    }
}
"@
}

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = [dummy]::GetDelegate()

Source: https://stackoverflow.com/questions/36456104/invoke-restmethod-ignore-self-signed-certs

from snipeitps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.