Archive for the ‘CommandLine’ Category
Posted by jpluimers on 2014/03/11
Edit 20250107: added various [Wayback/Archive] archived links (dated as close to the blog post as possible) because of link-rot; marked some keywords as code; found the current .NET DiscUtils repository at [Wayback/Archive] GitHub – DiscUtils/DiscUtils: Utility libraries to interact with discs, filesystem formats and more where you also can download it.
.NET DiscUtils is an interesting open source .NET library for accessing and manipulating virtual disk images. Since it is entirely written in C# (without the need for P/Invoke), you should even be able to run this on non-Windows machines using mono. Later on, you will see the 0.11.0 build fails this, but it gives good hope it eventually will.
Virtual disk formats supported are DMG, ISO, RAW (IMG/IMA/VFD/FLP/BIF), VDI, VHD, VHDX, VMDK, and [Wayback/Archive] XVA, regular disks like Physical, iSCSI and NFS.
There are two ways of getting the .NET DiscUtils tools to run:
- [Wayback/Archive] download pre-build binaries (at the time of writing: version 0.10) from via [Wayback/Archive] .NET DiscUtils – Home, or
- from the [Wayback/Archive] latest source page, click the download button, then build the binaries from the source package. At the time of writing, that version is 0.11.
This post describes the second way, and requires PowerShell to be installed on your system (which probably is, as Windows 7 and Windows Server 2008 R2 include it). Read the rest of this entry »
Posted in .NET, .NET 4.0, .NET 4.5, C#, C# 4.0, C# 5.0, CommandLine, Development, PowerShell, Software Development | 1 Comment »
Posted by jpluimers on 2014/03/05
A while ago I found a blog post explaining how to shortcut testing NULL values with PowerShell.
Do not do that!
I agree with the quote on the blog:
One thing you may not forget is that Powershell is a lot more friendly for NULL values than C#, so don’t forget to check your objects for NULL values. In Powershell this is very clean and easy to do.
But it is also easy to get wrong:
To see if a variable is null, simply check:
If (!$Variable) {some action}
Conversely, to verify if the variable has any value:
If ($Variable) {some action}
Just a few examples. Now quess the outcome for all of them.
$a=$null; if ($a) {"'$a' has VALUE"} else {"'$a' is NULL"}
$a=$false; if ($a) {"'$a' has VALUE"} else {"'$a' is NULL"}
$a=0; if ($a) {"'$a' has VALUE"} else {"'$a' is NULL"}
$a=''; if ($a) {"'$a' has VALUE"} else {"'$a' is NULL"}
$a=""; if ($a) {"'$a' has VALUE"} else {"'$a' is NULL"}
$a=1; if ($a) {"'$a' has VALUE"} else {"'$a' is NULL"}
Now take an educated guess on the outcome. Read the rest of this entry »
Posted in .NET, CommandLine, Development, PowerShell, Software Development | Leave a Comment »
Posted by jpluimers on 2014/03/04
You can check out which PowerShell you have by executing the $Host.Version or $PSVersionTable.PSVersion on a line. You can even switch versions by applying the PowerShell -version switch on the command-line and they will both change.
One of the great features of the new PowerShell 3.0 features (besides New and Improved PowerShell 3.0 Cmdlets) is a simplified Where Filter Syntax.
So: this is how I get the PowerShell version information the easy way from a command prompt:
PowerShell $PSVersionTable.PSVersion
–jeroen
via:
Posted in .NET, CommandLine, Development, PowerShell, Software Development | Leave a Comment »
Posted by jpluimers on 2014/02/26
In most programming environments, I tend to avoid abbreviations, especially since command-completion and parameter-completion makes it easier to write readable code.
Same fore PowerShell: the PowerShell ISE has great completion features.
Other people tend to use abbreviations, especially since many PowerShell aliases make it easier for people coming from a cmd or bash background.
Two Get-Alias commands I use quite often for researching aliases:
Get-Alias -Definition <name>
Get-Alias | Sort-Object Definition
The former gives you the CmdLet for an alias.
The latter all defines alises sorted by the CmdLet definition.
Two aliases that I tend to avoid are these:
While you are at it, there are also parameter aliases. Read Weekend Scripter: Discovering PowerShell Cmdlet Parameter Aliases on TechNet Blogs to learn more about these.
–jeroen
via: Top Ten PowerShell Aliases for DOS Commands.
Posted in .NET, CommandLine, Development, PowerShell, Software Development | Leave a Comment »
Posted by jpluimers on 2013/06/27
Once every while PowerShelll users get an error like this:
PS C:\bin> . .\DownloadedScript.ps1
. : File C:\bin\DownloadedScript.ps1 cannot be loaded.
The file C:\bin\DownloadedScript.ps1 is not digitally signed.
The script will not execute on the system. For more information, see about_Execution_Policies at
http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
+ . .\DownloadedScript.ps1
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
PS C:\bin>
I recently had it too, but was surprised this happened as I took the steps in my previous blog posts on this topic: Read the rest of this entry »
Posted in CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2013/05/09
Posted in .NET, C++, Cloud Development, COBOL, CommandLine, Delphi, Development, Fortran, iSeries, Java, Pascal, RegEx, Scripting, Software Development, Web Development, xCode/Mac/iPad/iPhone/iOS/cocoa | 3 Comments »
Posted by jpluimers on 2013/04/30
Precision Computing is a site by Lee Holmes having a great blog with PowerShell tips. Of course he does, as he is part of the PowerShell team and he wrote Windows PowerShell Cookbook: The Complete Guide to Scripting Microsoft’s New Command Shell.
The Counting Lines of Source Code in PowerShell entry is on counting C# code lines (and shows some great performance optimization tips).
I knew about the blog, and bumped into the entry because of file – Lines-of-code counting for many C# solutions – Stack Overflow.
Last year I inherited a suite of .NET projects totaling about 4 million LOC. Which I want to drastically reduce to make it more maintainable.
–jeroen
Posted in .NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, CommandLine, Development, PowerShell, Software Development | Leave a Comment »
Posted by jpluimers on 2012/08/15
A few weeks ago, Bill Karwin did a must watch webinar on the prevention SQL Injection titled “SQL Injection Myths and Fallacies“.
Bill Karwin (twitter, new blog, old blog, Amazon) is famous for much work in the SQL database community, including InterBase/Firebird, mySQL, Oracle and many more.
He also:
Anyway, his webinar is awesome. Be sure to get the slides, watch the replay, and read the questions follow up.
Watching it you’ll get a better understanding of defending against SQL injection.
A few very valuable points he made: Read the rest of this entry »
Posted in .NET, .NET 3.5, .NET 4.5, .NET ORM, ASP.NET, Batch-Files, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C++, Cloud Development, COBOL, CommandLine, Database Development, Delphi, Delphi for PHP, Delphi x64, Delphi XE2, Development, EF Entity Framework, F#, Firebird, FireMonkey, History, InterBase, iSeries, Java, JavaScript/ECMAScript, Jet OLE DB, LINQ, LLBLGen, MEF, Microsoft Surface, Mobile Development, PHP, PowerShell, Prism, Scripting, SharePoint, SilverLight, Software Development, SQL, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7, VB.NET, VBS, Visual Studio 11, Visual Studio 2002, Visual Studio 2003, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, Visual Studio and tools, Web Development, Windows Azure, WinForms, WPF, XAML, xCode/Mac/iPad/iPhone/iOS/cocoa | 1 Comment »
Posted by jpluimers on 2011/08/24
I needed an automated way of inspecting the local LAN.
The batch files below will on IPv4 networks, with thanks to articles from Windows IT Pro and Rob van der Woude for some ideas:
- find the TCP/IP gateways/netmasks
- enumerate all the IP addresses on each subnet (assuming the netmask is 255.255.255.0)
- ping each IP address and get ARP info, and dump that to the console
There are other tools that can do this too (like Angry IP Scanner), and more but the ones I tried could not copy the output to the clipboard.
find local subnets: Read the rest of this entry »
Posted in Batch-Files, CommandLine, Development, Power User, Scripting, Software Development | 4 Comments »