I would like to get the PID of my powershell script. I'am able to do that in bash like that :
#!/bin/bash
VARIABLE=$$
echo "This is a test"
echo $VARIABLE
The output is :
root@DESKTOP-TURGKNS:~# ./test.sh
THIS IS A VARIABLE
218
And if I execute the script again, the PID change every time.
In powershell, if I try that :
$PID
Write-Output "THIS IS A TEST"
The output is :
PS C:\Windows\system32> $PID
Write-Output "THIS IS A TEST"
5520
THIS IS A TEST
PS C:\Windows\system32> $PID
Write-Output "THIS IS A TEST"
5520
THIS IS A TEST
PS C:\Windows\system32> $PID
Write-Output "THIS IS A TEST"
5520
THIS IS A TEST
I think that $$ and $PID don't work in the same way.
There is someone to show me how to do that ?