Questions tagged [powershell]

Apply this tag to questions related to any version of PowerShell.

PowerShell is a Microsoft .NET based general purpose script language. It is well integrated into Microsoft Windows, which makes it very useful for system management tasks.

Still primarily being a Windows-bound technology, there are Open Source initiatives supported by Microsoft to make it available on Mac OS X and some Linux distributions.

17 questions
20
votes
4 answers

Are there well-known PowerShell coding conventions?

Are there any well-defined conventions when programming in PowerShell? For example, in scripts which are to be maintained long-term, do we need to: Use the real cmdlet name or alias? Specify the cmdlet parameter name in full or only partially (dir…
Tahir Hassan
  • 317
  • 2
  • 5
7
votes
2 answers

Correct way to initialize variables in PowerShell

Is there a preferred practice around initialising variables which are first defined within a branch of code, or is this purely subjective / personal preference? i.e. there are multiple ways this can be done; the most obvious of which are…
JohnLBevan
  • 425
  • 2
  • 4
  • 13
5
votes
1 answer

How is Pash licensed?

Pash is an open source reimplementation of Windows PowerShell. It was released in 2008, and has been idle since then. I would like to take up the mantle. It's not clear what the license is. There is no LICENSE file or license details in the…
Jay Bazuzi
  • 1,604
  • 3
  • 13
  • 19
4
votes
1 answer

PowerShell performance when running Excel macros

I run on a daily basis a set of VBA-rich Excel files. Most of them include MS Office application cross-talk, but also employ third-party applications and MySQL. Due to the fact of running those files in a specific order and at a specific time of day…
Oskar_U
  • 151
  • 5
2
votes
1 answer

Best practice to avoid unintentional side-effects in powershell-scripts

I recently wrote a small PowerShell script to clean a Visual Studio solution. It's used by a small team of 5 persons on a regular basis. I built it in PowershellISE (GUI client) and it works great, but some time later I ran it from Cmd and then…
David
  • 275
  • 2
  • 10
2
votes
1 answer

What are the best practices to design a "verbose" mode in command line scripts?

To improve my command lines scripts, I want to add some optional console output, mainly for logging purposes. In my PowerShell modules, I use Write-Verbose for this (but it should be clear this isn't specifically a Powershell question, presumably,…
Alex_P
  • 151
  • 7
2
votes
0 answers

Enum versus ValidateSet

Currently, in my PowerShell scripts I am using [ValidateSet()] in my functions in order to limit the options for user input. Now I discovered the Enum as an alternative. I have read a couple of blogs about Enums vs ValidateSet, i.e.…
Alex_P
  • 151
  • 7
2
votes
2 answers

Should powershell be used to develop a whole application?

We are automating the testing on an Web ERP solution (Dynamics) through a tool (RSAT, which uses selenium) provided by the developer of the ERP (Microsoft). The RSAT has a list of instructions to do some actions on the pages and it takes the values…
2
votes
1 answer

How to convert a powershell script to opensource `.exe`?

To make an installation of opensource software for the Windows platform single click, I am trying to convert the setup.ps1 into a setup.exe file. (To make a powershell script executable in a single (double) click, the user might/is still required…
a.t.
  • 225
  • 1
  • 11
2
votes
1 answer

Custom object formatting caveats as to not confuse end users

Default display of objects in the Windows PowerShell console In PowerShell you have format.ps1xml documents. These are used to simplify what and how object data is shown to the end user. A simple default example would be Get-Process. If no changes…
Matt
  • 129
  • 3
1
vote
0 answers

Continous integration of only MyCompanies nuget packages

I am trying to do a nightly package integration with one of our projects that consumes 6 other internal teams’ -PreRelease packages. Background Info We have our own internal ProGet Server that hosts only our company packages. Package IDs are in…
Flightdeck73
  • 119
  • 1
1
vote
1 answer

Should Write-Debug statements be left in production PowerShell code?

This is one of my functions I have in a module: Function Get-DatabaseUser { [CmdletBinding()] Param() Write-Verbose 'Getting database...' $Database = Get-Database Write-Debug('Value of $Database: {0}' -f $Database) …
Jake
  • 163
  • 6
0
votes
1 answer

Refactoring powershell codebase to support multiple environments

I come from a Java background, but now I'm supporting a PowerShell code base. In the PowerShell code base there are multiple modules that were written against a certain Azure environment. Now, we have another Azure environment that we need to…
0
votes
0 answers

Typical Practice for external application config

I have a C# cmdlet(1) that uses "ConfigurationManager.AppSettings" to get database connection strings necessary for some stored procedures used in the cmdlet(1). If another application instantiates an instance of the cmdlet(1) class object, then…
Rayshawn
  • 279
  • 1
  • 2
  • 12
0
votes
1 answer

Unix way of filtering/mapping/mapcatting records via the pipeline?

At home I use Linux and have for more than a decade. At work we use Windows and so I find PowerShell more familiar. I am a Linux/Unix fanboy at heart, but I've had greater success grokking the PowerShell pipeline. The model of pipelining objects…
Mario T. Lanza
  • 1,700
  • 1
  • 13
  • 22
1
2