• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Think PowerShell

PowerShell for IT Pros

  • About
    • Who I Am
    • Why I Blog
    • Privacy Policy
  • Resources
    • More PowerShell Sites
    • Post Series Index
  • Get Help
  • Show Search
Hide Search

Automatic Variables

Test PowerShell Variable for Null, Empty String, and White Space

Aaron Rothstein · Oct 25, 2017 · 6 Comments

Learn the difference between a null, empty string, and white space value for a PowerShell variable and how to test for them.

PowerShell variables without “value”

More often than not, we create variables with the intent they will hold a value. We typically then choose to act upon that value. Therefore, if a variable doesn’t have value, this is something we would want to check against in our conditional logic flow.

[Read more…] about Test PowerShell Variable for Null, Empty String, and White Space

Add Script Flexibility with Relative File Paths

Aaron Rothstein · Feb 15, 2016 · 11 Comments

Folder Contents Screenshot

Using relative file paths for your PowerShell script’s supporting files ensure it continues to work when the script and files get moved around. Here’s how.

Unpredictable File Paths

My first intensive use of PowerShell was for scripting software installations/configurations in SCCM packages. It seemed like every situation called for something above and beyond a straightforward MSI install.

I would develop and test the SCCM package on my local system with a sandbox VM prior to deploying in SCCM. The SCCM client would then download that package to a cached location on each individual client. From development to deployment, I couldn’t guarantee the absolute file path of my script and any supporting files would be constant. I needed my script to be able to figure out where the supporting files were in relation to itself.

[Read more…] about Add Script Flexibility with Relative File Paths

Primary Sidebar

Aaron

Follow

Copyright © 2023 · Monochrome Pro on Genesis Framework · WordPress · Log in