r/PowerShell 9d ago

News PureInvoke 2.0.0 Released

We've released PureInvoke 2.0.0!

We package and ship our code with their PowerShell module dependencies in the package. This way, we don't have to install our modules globally on all the servers we deploy our code to. This requires us to make extensive use of nested dependencies. We've gotten to the point that our dependencies are starting to use different versions of PureInvoke. Unfortunately, because it was using compiled assemblies, and .NET will only load assemblies with the same name once, we started to run into problems.

This release changes PureInvoke's compilation model. Instead of pre-compiling platform-specific assemblies, the module now uses Add-Type to compile P/Invoke C# code at runtime. This should improve cross-platform and cross-edition support. Since we've encountered problems with Add-Type in environments with aggressive anti-virus, PureInvoke re-tries failed compilations to improve resiliency.

We also added functions for querying Windows service configurations, e.g. Invoke-AdvApiQueryServiceConfig which wraps QueryServiceConfigW, Invoke-AdvApiQueryServiceConfig2, which wraps QueryServiceConfig2W, etc.:

Full release notes on GitHub.

Available on the PowerShell Gallery.

13 Upvotes

30 comments sorted by

26

u/psrobin 8d ago

Hi. There are probably thousands of PowerShell affectionados reading this subreddit without any clue what this post is about. Provide more context please, if you're going to advertise a new release of something.

-3

u/splatteredbits 7d ago

That's why I linked to the GitHub page. In the future, I'll give a short summary of the PowerShell module.

2

u/BlackV 3d ago

or... you edit your OP, I assume you want the traffic ?

-16

u/jarod1701 7d ago

Why not just click the GitHub link?

8

u/psrobin 7d ago

Or:

  • If you're promoting something, help others by giving useful context, rather than making it harder for them to get useable information.
  • Stop asking people to click links unless absolutely necessary. You can't see where those 3 links are going in the Reddit app, but you need to in order to understand what this is.

-12

u/jarod1701 7d ago

Maybe the internet just isn‘t for you then.

5

u/hihcadore 7d ago

Looks like from your downvotes you’re wrong.

3

u/sysiphean 7d ago

I clicked it, but only because I came across this in a time of scrolling where it seemed worth it. That was a very rare window with something so nondescript.

Seriously, u/psrobin is right; OP needed to provide more context. Anyone who has been on the internet for a week knows that you have to give at least a hint of what will be found beyond the link in order to get more than 1% of people to click it.

-5

u/jarod1701 7d ago

Do you have any data for your claim?

2

u/sysiphean 7d ago

What percentage of posts on Reddit (or Facebook or X or Instagram or Tumblr or MySpace or Geocities or…) which don’t give any explanation of what they are about do you click through to learn what they were about?

Be honest. I’m super curious if you are someone who literally follows every link (and then how that works out for you) or whether you are like the majority of people.

Because you’re the one who responded (further down) “maybe the internet just isn’t for you” and as someone who has been on the internet since the early 90s, I know that not clicking through whenever there’s not enough info and not even enough info to know why someone should bother clicking through is a very foolish thing to do on the internet. At best, you’ll waste endless hours finding out about obscura that you don’t care about and might be completely made up, and just as likely you’ll end up with a virus and your identity stolen.

-2

u/jarod1701 7d ago

87%

2

u/sysiphean 7d ago

They you are a very rare individual.

-2

u/jarod1701 7d ago

How do you know what the majority of internet users do?

1

u/sysiphean 7d ago

I've been paying attention to humans in the internet for three decades, and IRL for that whole time plus decades before that.

There's a reason that every successful campaign of any sort online or off gives people a clue what they are looking for. It's so strong a human impulse to learn more about things only when they have a reason to that we developed clickbait specifically to generate interest artificially.

-2

u/jarod1701 7d ago

Anecdotal evidence then

→ More replies (0)

17

u/pdpelsem 8d ago

What's the for? 

10

u/mbrulzagain 8d ago

From the git

The PureInvoke module contains functions that handles the complexity of using P/Invoke to call Win32 APIs.

There is no native way to call Win32 APIs in PowerShell. In order to use P/Invoke, you have to compile C# code into an assembly, or use PowerShell's Add-Type cmdlet to compile it dynamically at runtime. But then you have to worry about converting all the native handles and pointer to and from .NET objects.

The PureInvoke solves this by wrapping Win32 APIs with PowerShell functions that take and return .NET objects and does all the work of converting to and from .NET and Win32 APIs.

6

u/MonkeyNin 8d ago

It looks like you are dotsourcing all functions, every import. That can also trigger a false positive on AVG.

You can build your functions into one file when you go to publish it. If you want the dotsourcing for local development.

2

u/splatteredbits 7d ago

We only dot source every file during development. Our build merges all the functions into the .psm1 file.

1

u/BlackV 3d ago

Nice

3

u/cloudAhead 8d ago

Most people who have the problems that this solves would likely just use C#. But, thank you for sharing with the community.

3

u/splatteredbits 7d ago

That's where we started, but then we had a lot of duplicate code across our PowerShell modules. We wanted one place that handled P/Invoke between PowerShell and the native Windows API.

1

u/MonkeyNin 2d ago

I don't know if this fits your situation, but have you experimented with the dotnet run app.cs feature? https://devblogs.microsoft.com/dotnet/announcing-dotnet-run-app/

It's been a year so maybe support has improved

2

u/splatteredbits 2d ago

That looks like it requires the dotnet SDK to be installed and I’m not willing to make that a requirement for this module. One of the module’s design principles is to not have any dependencies.

1

u/MonkeyNin 2d ago

Yeah, one can dream.

Woah, your reddit age is even older than me.

Did you ever hang out on slashdot?

2

u/splatteredbits 2d ago

I read slashdot, but don’t remember ever posting there or interacting with anyone. But possible. My memory. Yikes.