You need first to read the content of your file before you can start processing it. To read a file using PowerShell, you can use the Get-Content
cmdlet.
Once you got the content of your file, you need to convert it to a type that you can use for doing calculations, i.e. you need to do a type-cast.
Type casting you can do like this, assuming the variable $num
is a string:
[int]$num
this will create an integer out of a string.
You can check the type of a variable by using the Get-Member
cmdlet.
Putting all this together:
# For the sake of it, let's create a file containing a single number
"2" | Out-File -FilePath .\number.txt
# Let's read the file we just created and save the result in a variable
$num = Get-Content .\number.txt
# Do the type cast and multiply the result with another number
[int]$num * 2
You can at any point pipe the result to Get-Member
and check what type it is.