How do I get a list of functions/methods/properties from a DLL? - powershell

I have been "Dev Neutered" for a long time now and know enough powershell but not enough to solve this problem...
my kids have asked if I can write a script that returns the date of an event in a game and that game has an interface DLL that has the commands but I don't know what it is called or what is properties are.
So I was wondering if I can get some help on this. Basically I want to get a list of methods I can call and what the parameters required and what the results returned would be.
a Sample Powershell would be awesome! the DLL in question can be found at "https://7dtd.illy.bz/wiki/Server%20fixes"
thanks a ton!!

you can use these applications ( both free)
ILSpy: https://apps.microsoft.com/store/detail/ilspy/9MXFBKFVSQ13
dotPeek: https://www.jetbrains.com/decompiler/

Related

Write to parameter value in Adaxes PowerShell action

This is a question about using PowerShell with Custom Commands (or scheduled tasks) in the Adaxes Active Directory management software by Softerra.
I am trying to accept a parameter from a user when using a custom command, then I need to take that value and modify it for use in a future action of the custom command.
A "for example" use-case would be creating a script that sets a user's out of office, where the custom command takes a target user reference in the out of office message. The first action in the custom command would find the email address of the provided user, then the second action would set the out-of-office with a message telling recipients for immediate assistance to email the provided user's email address. I realize there may be ways to solve this with one PowerShell script, but there are MANY scenarios where it would be beneficial to process provided information with a script action for use with MULTIPLE future actions in the custom command.
I already know how to access parameter values in custom commands for Softerra Adaxes, but I can't figure out how to WRITE to parameter values.
Accessing values:
$context.GetParameterValue('param-Example')
Does anyone know how to write TO parameter values? $context.SetParameterValue() does not work. This would be extremely useful for being able to store and manipulate values between actions in custom commands in Adaxes.
If anyone is looking for something similar, the answer I got from Adaxes support was that there is no means to do this currently with their software.
The only work-around would be writing to a property of the object being modified, then reference that property later.
For instance, writing a value to the extensionAttribute1 property of a user, then referencing that later in the script in a different action.
If anyone comes up with a better solution or Adaxes changes this, please feel free to suggest a better solution!

PowerShell middleware to wrap powershell module commands

I am looking for a middleware pipeline option for PowerShell. That means I want to provide each function with pre and post statements for a module that is not a C# cmlet.
Is there already something in this direction?
The background is that I don't want to store debug functions at every command but want to measure all my functions at a central place.
Thanks a lot
There is no way to put code in front of a call to a cmdlet, or after like you can when writing your own functions or using something like try\catch\finally. You cant really emulate that type of a work flow with cmdlet calls that I have found.

How do I Call SMSFormatMessageCtl.FormatModuleMessage?

I'm attempting to query the server for particular status messages and build the string format of them. The status message data doesn't contain the translated strings. They appear to be stored in srvmsgs.dll in the install directory for the console.
I see some "documentation" (proof that it exists, not help for using it) about the FormatModuleMessage method of SMSFormatMessageCtl. Sadly, there are no examples that I can find. This guy mentions that he has gotten it to work, but he doesn't provide details. In fact, I cannot even find the DLL referenced (FormatMessageCtl.dll) on my computer. StatView.EXE (the status message viewer app that comes with the client) exists, but running the dependency walker on it doesn't reveal any overt reference the desired .DLL.
Can this be done in VBScript or, preferably, PowerShell? I'm actually using Perl, but this is probably less common and nearly impossible to find meaningful code examples for. A working VBScript or PowerShell example would be a good place to start.
“About Configuration Manager Component Status Messages” has an example, but I think it’s in C# or C++.
Any suggestions on how to accomplish this?
I'm that guy. It's been 2 years, but I think the way I did it was that first I did a regsvr32.exe for the dll to register it, and then I just created an SMSFormatMessageCtl object through COM
For PowerShell that would be
New-Object -COMObject SMSFormatMessageCTL
For Perl, it's been even longer, but if I recall correctly, that would be
Win32::OLE->DispatchEx('SMSFormatMessageCtl');
Once you have the object you can call the FormatModuleMessage method, and don't forget the part about doing a bitwise OR of the Severity and MessageID from the WMI objects.

Perl: Determining where a function is defined [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
In Perl, how can I check from which module a given function was imported?
Hi guys!
I am using my weekend time to comb through our web app to get a better understanding of it. It uses numerous modules whose functions get pulled into it and my question is this.. how can I determine the module where a function originates?
Reason I ask is because I am using print STDERR lines sprinkled here and there to understand the way data moves around (it has demystified things greatly).. here's an example....
($file_data,$count) = lookup_files($customer,$site,'','0',$d);
What I'm not sure of is where lookup_files() is originating from. What I'd like to see is this....
($file_data,$count) = lookup_files($customer,$site,'','0',$d);
print STDERR "lookup_files originates here " . <CODE TO SHOW ME WHERE lookup_files IS DEFINED>;
Any advice on where to begin would be greatly appreciated. The webapp uses tons of use modules and instead of selectively importing only what's needed, each use seems to bring all functions in.
I know my terminology might be incorrect when referring to "method", "parent" and so on in regards to Perl. If anyone would like to correct me on it that would be appreciated too. I am at best a beginner with this stuff. Janie
Take a look at the core module Devel::Peek
http://perldoc.perl.org/Devel/Peek.html#A-reference-to-a-subroutine
The output of that module's functions will tell you where a subroutine comes from
One fairly easy way is to load Carp::Always. If it’s a web app, you’ll need to put it in the code. For a command line you can just perl -MCarp::Always ...

Powershell in SQLCLR?

In the past I've been able to embed a sripting languate (like JScript) inside the SQLCLR, so scripts can be passed as parameters of functions, to perform certain calculations. Here is a simplistic example (the function ssScriptExecute returns a concatenation of all the print's in the script):
select dbo.ssScriptExecute( 'print("Calculation: "+(1+2/3) );' )
-- Calculation: 1.6666666666666665
I'd love to be able to embed a Powershell runtime in the same way. But I've had all sort of problems because the runtime tries to find assemblies by path, and there are no paths inside the SQlCLR. I'm happy to provide more information on the errors I get, but I was wondering if anybody has tried this!
Thanks!
I use il code injection to modified System.Automation.Management.
make variable version in GetPSVersionTable() be "2.0"
then i can run Powershell Code in SQL Server.
Be sure reference this modified dll in your visual studio project.
http://www.box.net/shared/57122v6erv9ss3aopq7p
btw, automated registering all dll you needed with running powershell in SQL
you can use this ps1 code
http://www.box.net/shared/tdlpu1875clsu8azxq4b
I think the only way to do this is to create a WCF service hosting powershell, and let SQLCLR send the request dbo.ssScriptExecute(...) to that service for execution.
Besides from that, I've also successfully embedded paxScript.net in the SQLCLR (an interpreter that does not have the memory leak problems of the DLR languages).
I thought SQLCLR was restricted to just a certain set of assemblies and PS Automation is not one of them.