Stream

Join this community to post or comment

Mike Shepard

Discussion / Questions  - 
1
Add a comment...

Parrish Sims

Educational / Tutorials  - 
 
Hey Gang,

So has anyone tried out this script? Since I cannot find PowerGUI anymore I was resorting to having to make my own exe with my Powershell script in it in .NET if I wanted executable PS code. I know some will say why I didn't make it in pure C# .net managed code versus a wrapped script. Well, the scripts are usually small and I had a working prototype I knew worked in Powershell so all I had to do was plug it into my .NET template and compile. Well, I recently found this script. It is kinda out dated a little. For example, I had to add in it to detect Powershell 5 else it will fail if you have PoSH 5 installed. That would be after line 74 in the ps2exefunc.ps1 file where you add a check like so along with the other checks:
if($PSVersionTable.PSVersion.Major -eq 5) {
$psversion = 4
write-host "You are using PowerShell 5.0."
}

After I had a working copy of the function, I began to modify it. I took out all the write-hosts and replaced with write-verbose. I redid the verbose and debug switches so they worked with the cmdletbinding() commands. I have it throw excepts to stop it at spots that need to be completed to be carried on and then began to make the code more smarter. Example is the compiler needs the full path but the cmdlet doesn't check nor fix it if there is no full path given. I have an except there for now until I get around to adding something there to correct that. Also, I removed the runtime switches because the 2.0 one tries to fire off another instance of itself with the commandlines. I plan on making it suck itself in as a scriptblock and fire off as a job with the "-psversion 2" parameter.

In all and all it works. Funny thing is the author says it follows the execution policy. The cmdlet to compile it to an executable has to follow the execution policy but the resulting exe does not. I tested with a restricted policy and my test exes still ran. I figured seeing it is using the Automation assemblies vs Powershell.exe.

Anyway, if you are looking for a way to run your powershell script as an exe. This cmdlet is not bad at all, just needs a little TLC.

Maybe when I have the copy I am messing with completed with my additions, I will post it to Github.
4
2
Parrish Sims's profile photoAnthony Ciccone's profile photo
5 comments
 
My go to as well for exe compiler, also great for making a ps1 isn't a Windows service. Loading GUi's when an exe are painfully slow tho. 
Add a comment...

Deborah P

Educational / Tutorials  - 
 
Make working with #Windows seamless and easy - Master #PowerShell with this free quickstart guide - http://bit.ly/Free-Tech-Learning (available only today).

What You Will Learn:
• Learn to verify your installed version of PowerShell, upgrade it, and start a PowerShell session using the ISE
• Discover PowerShell commands and cmdlets and understand PowerShell formatting
• Use the PowerShell help system to understand what particular cmdlets do
• Utilise the pipeline to perform typical data manipulation
• Package your code in scripts, functions, and modules
• Solve common problems using basic file input/output functions
• Find system information with WMI and CIM
• Automate IIS functionality and manage it using the Web Administration module

3
3
Add a comment...

Parrish Sims

Discussion / Questions  - 
 
Hey All,

So I have had more thought on an earlier post I made about Powershell not being exploitable and it isn't except there is one part I believe to be an unintended exploit of it. That is how the execution policy is implemented.

The execution policy is there to restrict scripts from being run by requiring some criteria. Issue with this is it only affects script "files". Not adhoc scripts like running:
Powershell - C "$a=gci;write-host $a"

It is more than 2 lines thus should be consider a scripts but will run as it is interpreted as a command. No execution policy setting will stop this.

Reason being, Powershell.exe is just a program, it is the console app built by MS to help you run Powershell stuff. It includes tab completion, etc. In actuality, it is not needed to run Powershell commands as Powershell is woven into the OS in the .NET framework. The "System.Management.Automation" class to be specific. You can write your own Powershell.exe or whatever you want to call it and use that class to execute scripts. So, getting rid of Powershell is not an option as with bash and default python installations on Linux (since most tools in Linux are written in python or bash).

But, how can we improve PosH? I say implement execution policy down to the .net class. Implement it so any multi-commands are classified as a script. What about services that run Powershell scripts? Easy, implement the ability to assign powershell script rights to accounts (can we say service account). Now no matter how an attacker try to run the script via Powershell.exe - C "a command" or Powershell.exe - NonI - NoP - sta - Enc WOIEROPRIODJSJ, it will still fail if it is more than 1 command. This should translate to the commandlets too for Invoke-command, Start-Job, Register-<allthejobtypes>, and Invoke-Expression.

Just some ideas and running my fingers off at the keyboard since I am bored at work on Thanksgiving week. :-P

1
Parrish Sims's profile photo
2 comments
 
Figured it out. Didn't know about G+ formatting. Doh!! They need an escape character for that stuff. There are no spaces between my - . Had to add them to prevent the overstrike.
Add a comment...

Philip Tomson

Educational / Tutorials  - 
 
Version 0.6.6 of my ExcelPSLib Powershell Module is out !
You can find it on codeplex or via the Powershell Gallery ! Do not hesitate to rate it or comment it ! Enjoy !
ExcelPSLib is a PowerShell Module that allows easy creation of XLSX file by using the EPPlus 3.1 .Net Library
3
Philip Tomson's profile photo
3 comments
Add a comment...

Josh Millikan

Discussion / Questions  - 
 
I was wondering if anyone knew an answer to a problem i am having with powershell.

i have a script that pulls information for me. i also have another script that processes the information it pulls. i was wanting to integrate the 2 processes together, but keep them as separate scripts.
The issue i am having is when i call my other script it holds up the original script till  my second script is done.  Is there a way to spawn another process to process the second script so that it doesn't hold up my main script which can continue working?
1
Søren Siim Nielsen's profile photoJosh Millikan's profile photo
3 comments
 
thanks for the replys. i will give those a try when i get back to work.
Add a comment...

About this community

This community is dedicated to the education, adoption and promotion of Windows PowerShell.

Jeffery Hicks
moderator

Educational / Tutorials  - 
 
New from the blog: Creating GitHub repos from PowerShell http://bit.ly/2jgskzo
I’ve been continuing to work with the GitHub API in PowerShell. Today I have a function you can use to create a new GitHub repository. Of course you will need to have a GitHub account and ano…
8
1
Add a comment...

Ronald Pohle

Educational / Tutorials  - 
 
‘Sup PSHomies, It all started a year ago… Always wanting to learn anything PowerShell related, classes caught my eye ever since they were introduced in v5. I wanted to try my hand at classes…
20
9
Add a comment...

Jeffery Hicks
moderator

Educational / Tutorials  - 
 
Just posted: #PowerShell v6 Release Tools http://bit.ly/2iELf6A
As you should be aware, the next version of PowerShell is open source and cross-platform. You will be able to run PowerShell v6 on Windows, a Mac and select Linux distributions. All of the code is …
24
7
Jeffery Hicks's profile photoMike Shepard's profile photo
2 comments
 
Really nice illustration of how to programmatically deal with GitHub!
Add a comment...

dYaN mArQuEz

Discussion / Questions  - 
 
Is there a powershell script to test a SQL login in multiple servers. Let's say 3 different SQL logins having 10 servers each?
1
Robert Knott's profile photodYaN mArQuEz's profile photo
2 comments
 
Is it same in SQL? I got the error
New-Object : Cannot find type [MySql.Data.MySqlClient.MySqlConnection]: verify that the assembly containing this
type is loaded.
At \\prod.sbet.com.au\citrix\UserData\sa.dyanm\My Documents\Untitled1.ps1:7 char:15
+ $Connection = New-Object MySql.Data.MySqlClient.MySqlConnection($ConnectionStrin ...
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

WARNING: Connect to master on Host SDCWNUTDBTST01\OLTP14EETST01 failed. Error: You cannot call a method on a null-valu
ed expression.
You cannot call a method on a null-valued expression.
At \\prod.sbet.com.au\citrix\UserData\sa.dyanm\My Documents\Untitled1.ps1:18 char:5
+     $Connection.Close()
+     ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
Add a comment...
 
Today while surfing on the internet I came across very cool website for Microsoft Powershell, it is free powershell GUI designer tool online. Powershell lovers who like to create graphical interface will definitely like this website, if they want to create a GUI structure and put there code for automation, Its very easy one and helpful excellent tool. You can signup on the website, to Save or Load Form. on the left side there are few necessary controls, click on any of one and then click on form, it will be loaded visible on form, and Right had side control properties can be modified. If you want to delete the control select it and there is Delete control button on the top.
37
10
Tom Shuee's profile photoWilfred B's profile photo
14 comments
 
Thank you, that is awesome!
Add a comment...

Parrish Sims

Educational / Tutorials  - 
 
Why did I jump on PoSH 5 so early before it was done and happy it is available for Windows 7 and up? Classes. That is all. I wanted my classes. Making custom PSObjects was okay as a work around but being able to write in other languages makes you love creating custom class objects and dealing with classes. They are so easy with so many options.

Want a property that is an enum of set values, you can. Want to add static methods, you can. Want to create a class and use it is a type for something else, you can.

I have gotten use to using classes as my object tester from input like from a web service (like the dirty one I posted). When I get a JSON object back, I convert it back to psobject and then try and cast it to my Class. If it fits, most likely the input is correct. If not, you get a $null object in response.

I have always been more comfortable with creating and dealing with classes than I do with psobjects. Just feels and flows better for me. :-)
Summary: Ed Wilson, Microsoft Scripting Guy, talks about creating a simple class in Windows PowerShell 5.0 in Windows 10. Microsoft Scripting Guy, Ed Wilson, is here. The good news is that so far the weather person has been wrong—every single day for the last five days in a row. The bad news is that, well,...
13
4
Add a comment...

R.Pradheep Kumar

Discussion / Questions  - 
 
Greetings everyone

I need to setup the below values in Control Panel - Region settings in Windows server 2012
Measurement system = Metric
Short time: HH:mm:ss.
Long time: HH:mm:ss.
AM symbol: Leave blank.
PM symbol: Leave blank

I have average knowledge and currently learning power shell scripting.
Can anyone help me to script those settings in powersell 3.0


1
Anatolij “rising sun” Batmanov's profile photoR.Pradheep Kumar's profile photo
7 comments
 
Yes, I agree with +Anatolij Batmanov​
Add a comment...

Nandini Kumari R

Discussion / Questions  - 
 
Iwant to travel by ship..see the world possible before leaving this world..
1
Otto Gebb's profile photoNoah Jatta's profile photo
2 comments
 
Why not build the ship yourself as part of the fun
Add a comment...