Archive for the ‘CommandLine’ Category
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 »
Posted by jpluimers on 2011/08/10
Though there are API ways to add users to local groups in Delphi, you need the JwaLmAccess unit from the JEDI API library project to import those.
Sometimes that is not feasible, and sometimes you want to just script things.
For those, you can use the Windows net localgroup command (if you have sufficient privileges, you can even apply it to the local groups on your domain controller by appending it with the /domain parameter, or use the net group /domain command to execute on global domain groups instead of local groups).
Sample of using this in a cmd script:
net localgroup Guests Me Myself I ACME\BugsBunny /delete
It will remove the local users Me, MySelf and I, and remove the domain user ACME\BugsBunny from the local group Guests.
Sample source of using this in Delphi: Read the rest of this entry »
Posted in CommandLine, Delphi, Development, Software Development | 1 Comment »