You can use the -as operator. If casting succeed you get back a number:
$numberAsString -as [int]
More Related Contents:
- Get-Aduser -Filter will not accept a variable
- In what scenario was Invoke-Expression designed to be used?
- Powershell executable isn’t outputting to STDOUT
- How to escape special characters in PowerShell?
- Function return value in PowerShell
- Read file line by line in PowerShell
- how do I loop through a line from a csv file in powershell
- Access PSObject property indirectly with variable
- How to remove all quotations mark in the csv file using powershell script?
- Is there a way to set a variable up to place output to stdout or null?
- Custom RoboCopy Progress Bar in PowerShell
- Executing an EXE file using a PowerShell script
- Set-Content appends a newline (line break, CRLF) at the end of my file
- Get current user’s credentials object in Powershell without prompting
- Redirect Write-Host statements to a file
- How do I execute a PowerShell script automatically using Windows task scheduler?
- How to export data to CSV in PowerShell?
- Powershell ConvertTo-json with embedded hashtable
- Waiting for user input with a timeout
- VS code terminal can’t find AWS SAM even though windows terminal can
- Script has two variables when done, but when I pipe to SELECT-object only first one returns data to console
- Why do integers in PowerShell compare by digits?
- How can I find the source path of an executing script? [duplicate]
- ConvertTo-JSON an array with a single item
- Start-process raises an error when providing Credentials – possible bug
- PowerShell The term is not recognized as cmdlet function script file or operable program
- Powershell: resolve path that might not exist?
- PowerShell is missing the terminator: “
- Using PowerShell to remove lines from a text file if it contains a string
- How to execute a PowerShell script only before a web deploy Publish task in VS 2012?