Export (0) Print
Expand All
Expand Minimize

Converting VBScript's TypeName Function


Windows PowerShell


Definition: Returns a string that provides Variant subtype information about a variable.

TypeName


In system administration scripting it's often useful to know what type of a variable you're working with; for example, databases don't like it if you try to save string data into a field reserved for numeric data. In Windows PowerShell you can use the GetType() method to determine the variable type of any variable. For example, the following set of commands assigns the value 55.86768 to the variable $a, then uses GetType() to retrieve the Name of $a's variable type. The resulting type name is assigned to the variable $b:



$a = 55.86768
$b = $a.gettype().name

When you run this command and then echo back the value of $b you should get the following:



Double


Return to the VBScript to Windows PowerShell home page

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft