The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,811 other followers

Archive for the ‘PowerShell’ Category

Anyone having a solution for “Microsoft Visual Studio” throwing “The operation could not be completed” when including a file in a PowerShell project?

Posted by jpluimers on 2017/06/22

The operation could not be completed.

The operation could not be completed.

Include In Project

Include In Project

I’ve got a bunch of PowerShell projects in a solution. In some of them, I can include new files, in others I get the below error.

The diff of a good/bad project is below as well.

Two questions:

  1. Does anybody know how to work around this?
  2. Does anybody know how to find the actual error for this?

---------------------------
Microsoft Visual Studio
---------------------------
The operation could not be completed
---------------------------
OK
---------------------------

Good file: WindowsLogsCbsInquiry.pssproj

Bad file: WindowsTempInquiry.pssproj

–jeroen

Read the rest of this entry »

Posted in CommandLine, Development, PowerShell, Software Development, Visual Studio 2015, Visual Studio and tools | Leave a Comment »

PowerShell: when Format-Table -AutoSize displays only 10 columns and uses the width of the console when redirecting to file

Posted by jpluimers on 2017/03/09

Lets start with the second problem: There are various ways to redirect PowerShell output to a file.

  • Shell redirect with a greater than sign (>) to create/overwrite output or two greater than signs (>>) to append output.
  • Use Out-File [WayBack] with a filename and either -FilePath (default, similar to >) or -Append (similar >>).

I write “similar” as they are not fully equivalent. That’s where Format-Table [WayBack] with the -AutoSize parameter comes in (with or without a -Wrap parameter).

Apart from Format-Table displaying only 10 columns by default (see below), the -AutoSize will change columns presentation depending not just on the -Wrap parameter but also to the total width it thinks it has available.

Useful Format-Table parameters

First the representation:

Read the rest of this entry »

Posted in CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows | Leave a Comment »

Windows 10 – language neutral batch file to start Windows

Posted by jpluimers on 2017/02/22

A while ago, I bitched that Microsoft moved away the Windows Update out of the Control panel into a language depended place (in Windows 10 1511 update broke the Hyper-V networking – Fix network connection issues).

Since then I had to maintain too many locales running Windows 10. So here is the batch file:

for /f "delims=" %%A in ('PowerShell -Command "(Get-Culture).Name"') do explorer "%LocalAppData%\Packages\windows.immersivecontrolpanel_cw5n1h2txyewy\LocalState\Indexed\Settings\%%A\AAA_SystemSettings_MusUpdate_UpdateActionButton.settingcontent-ms"

It uses these tricks:

  1. Set output of a command as a variable (in this case a for loop variable)
  2. Execute PowerShell script in a .bat file
  3. PowerShell Get-Culture (which gets a .NET CultureInfo instance)
  4. CultureInfo.Name property (which has the nl-NL, en-US, etc codes in it)

It replaced this simple batch-file which has worked for like 10 years:

%windir%\System32\rundll32.exe url.dll,FileProtocolHandler wuapp.exe

–jeroen

via: Windows Update Shortcut – Create in Windows 10 – Windows 10 Forums

Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, Batch-Files, CommandLine, Development, Power User, PowerShell, Scripting, Software Development, Windows, Windows 10 | Leave a Comment »

Powershell 4.0 hates Lucida Console and switches to raster fonts

Posted by jpluimers on 2016/07/25

PowerShell 4.0 is madly in love with

PowerShell 4.0 is madly in love with “English (United States)”

A long time ago I started writing up my blog post like this in March 2015 when I bumped into this the first time when upgrading from PowerShell 2 to PowerShell 4:

It seems there is no real workaround:

Good and not so good news: after reading the below linked posts, this is what works:

  • PowerShell 4 and up works fine with any Lucida Console size (including 12) and boldness
    • only when the “Language for non-Unicode programs” is set to “English (United States)”.
  • PowerShell 4 works fine with Consolas on any size and boldness
    • for any “Language for non-Unicode programs”

So if you’re like me and switch between “Dutch (Netherlands)” and “English (Ireland)” a lot (both use the EURO as currency, but have distinct enough other locale settings to cover a lot of European stuff) then you need to get used to the Consolas font.

Source:

–jeroen

Posted in CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows, Windows 10, Windows 7, Windows 8, Windows 8.1, Windows 9 | Leave a Comment »

Get the full exe path name of running processes.

Posted by jpluimers on 2016/02/03

Every once in a while, I need to see which EXE paths.

In this particular case, I wanted to see which Spring.Tests unit tests instances of Sprnig4D werere running.

This case I needed to see which DevEnv were running (because somehow I got my .csproj bindings wrong).

Since tasklist nor pslist would cut it, I wrote two small batch files:

:

PowerShell to the rescue here: Both use the PowerShell Get-Process cmdlet.

First I used Get-Member to see what Get-Process could return:

PowerShell Get-Process ^| Get-Member

Then I filtered the Path from Get-Process to figure out which Spring.Tests processes were running:

PowerShell Get-Process Spring.Tests ^| Format-List Path

resulting in:

Path : C:\Users\Developer\Versioned\Spring4D\Tests\Bin\DelphiXE\Spring.Tests.exe

The second batch file escapes the pipe (|) by using a carret (^), so it is passed from the command-line to PowerShell.

–jeroen

Posted in CommandLine, Development, PowerShell, Software Development | 2 Comments »

 
%d bloggers like this: