I'm using Powershell.exe to access data on a Sharepoint server. The Powershell script fails if the installed version of Powershell is less than 3.
I'm trying to run the following vba code to determine which version of Powershell.exe is installed, so I can advise the user to update their Powershell:
When I manually run the cmdlet "$PSVersionTable.PSVersion.Major" in Powershell, I get the correct result ( 2 or 3 or 4). But when I run it within the above vba code, I get a random set of 3 or 4 numbers (different each time I run it).
Can anyone tell me why this vba code is not working properly? Or, can someone suggest another way to determine the installed version of Powershell?
Thanks,
Sup
I'm trying to run the following vba code to determine which version of Powershell.exe is installed, so I can advise the user to update their Powershell:
Code:
Dim intVers As Integer
intVers = Shell("Powershell.exe -executionpolicy bypass $PSVersionTable.PSVersion.Major")
MsgBox intVers
When I manually run the cmdlet "$PSVersionTable.PSVersion.Major" in Powershell, I get the correct result ( 2 or 3 or 4). But when I run it within the above vba code, I get a random set of 3 or 4 numbers (different each time I run it).
Can anyone tell me why this vba code is not working properly? Or, can someone suggest another way to determine the installed version of Powershell?
Thanks,
Sup