Get the App
SLTechnology News&Howtos  ›  Servers  › 

Powershell learns to understand empty strings

Shulou Source: shulou.com Published: 2022-06-03 00:30:11 10月03日 Update

Empty character strings are often output to the console during work, but intuitively it is not clear what character types and character values are input to the console.

For example, when querying disk space size, enter the following screen:

DriveLetter has empty logical volumes. I don't want to show empty volumes. How can I exclude these disks? According to my previous understanding of "null" value,"null" here should be $Null, and then there is the verification of the following command

Comparing DriveLetter with Null, the result is False. Later, I query the data type of this object and find that this data object is char type.

At this time, you can view the value of this data through data type conversion

Finally, I found out that the value representing "null" is actually 0.

And then through screening to get the ideal results

Tags: Data type character object console disk result control query input empty character clear intuitive representative information can be passed command size regular meeting time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Technology Huawei Apple MySQL