The last blog entry about script packages and elevation prompted Don Jones to ask if we consider adding a template to PrimalScript or even a manifest builder.
Truth is, manifests are so simple that this hardly seems necessary. Here is…
Read More
Microsoft Windows Vista and Server 2008 have become a lot more protective of certain areas of the registry and the file system.
Take an innocent little script that create a URL shortcut in a folder under C:\Program Files.
Not really…
Read More
http://confluence.atlassian.com/display/DEV/How+to+write+a+LDAP+search+filter is a great article on writing LDAP search filters.…
Read More
Use ‘single quotation marks’ around string literals unless you explicitly need variable expansion. In PowerShell, single quotes are not expanded into variables:
$var = ‘Hello’
$result = ‘$var $var’
# $result contains ‘$var $var’
Double quotes are:
$var = ‘Hello’…
Read More
Whenever possible, functions (especially) and scripts (to a lesser degree) should emit custom objects, not just text. This ensures that the output of these constructs can be piped to other cmdlets, like Where-Object, Sort-Object, and so forth, further extending PowerShell’s…
Read More
Develop a standard for formatting your scripts, and use indentation.
Function MyFunction {
# function code here
}
…or…
Function MyFunction
{
# function code here
}…
Read More
Aliases are harder to read and maintain over the long term – so try and avoid using them in a script. If you use PrimalScript, just select Edit > Convert > Alias to Cmdlet to turn all aliases into their…
Read More
Scripts, functions, and other elements should NEVER modify the variables, aliases, PSDrives, or other items from parent scopes. Instead, return data to the parent scope using the pipeline. Changing parent scope items creates code which is much more difficult to…
Read More
First you’ll need a code-signing certificate. If you purchase one, you’ll be looking for a “Class III” digital certificate of the “Microsoft Authenticode” variety. This will often come in two parts: An SPC file, which is the Software Publishing Certificate,…
Read More
These examples show how to run command-line tools from within a VBScript, capturing the tool’s output.
'
' ScriptingAnswers.com Essentials - by Don Jones
'
' Run cmdline tools
' This shows how to launch a command-line
' tool and…
Read More