Powershell studio seems to be reading script incorrectly

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 11 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
sekou2331
Posts: 318
Last visit: Sat Oct 28, 2023 7:46 am

Powershell studio seems to be reading script incorrectly

Post by sekou2331 »

Ran a script in Windows Powershell ISE and it works. WHeni i run the same secipt in Powershell studio i get the error below. Is there something that i need to turn off or on.

Code: Select all

	
	$MyList = @()
	
	$TDApps = "" | Select-Object Comptr, OS, username, SoftwareVersion Software2Version, Software3Version, Software4Version, Software5Version,  Software5Version,  Software6Ver, Software7Version
	
	if (Test-Path "C:Program (x86)Software") { 
	
	
	$TDApps.Comptr=(Get-wmiobject Win32_ComputerSystem).Name 
	
	$TDApps.OS=(Get-wmiobject win32_operatingsystem | Select-Object Version).Version 
	
	$TDApps.username=(Get-wmiobject Win32_ComputerSystem).UserName 
	
	$TDApps.SoftwareVersion= (. Get-Item "C:Program Files (x86)Software").VersionInfo.ProductVersion 
	
	
	$TDApps.SoftwareVersion= (. Get-Item "C:Program Files (x86)Software").VersionInfo.ProductVersion 
	
	 
	$TDApps.Software2Version= (. Get-Item "C:Program Files (x86)Software").VersionInfo.ProductVersion 
	
	
	$TDApps.Software3Version = (. Get-Item "C:Program Files (x86)Software").VersionInfo.ProductVersion 
	
	 
	$TDApps.Software4Version= (. Get-Item "C:Program Files (x86)Software").VersionInfo.ProductVersion 
	
	
	$TDApps.Software5Version = (. Get-Item "C:Program Files (x86)Software").VersionInfo.ProductVersion 
	
	
	$TDApps.Software6Version= (. Get-Item "C:Program Files (x86)Software").VersionInfo.ProductVersion 
	
	
	$TDApps.Software7Version= (. Get-Item "C:Program Files (x86)Software").VersionInfo.ProductVersion 
	}  
	$TDApps 
	

[/error]

ERROR: Select-Object : A positional parameter cannot be found that accepts argument 'System.Object[]'.
LastTestCheck.ps1 (11): ERROR: At Line: 11 char: 16
ERROR: + $TDApps = "" | Select-Object Comptr, OS, username, SoftwareVersion Software2Version, Software3Version, ...
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : InvalidArgument: (:) [Select-Object], ParameterBindingException
ERROR: + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SelectObjectCommand
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Powershell studio seems to be reading script incorrectly

Post by davidc »

I get the error in both the ISE and PowerShell Studio. What OS and version of PowerShell do you have installed?

David
David
SAPIEN Technologies, Inc.
User avatar
sekou2331
Posts: 318
Last visit: Sat Oct 28, 2023 7:46 am

Powershell studio seems to be reading script incorrectly

Post by sekou2331 »

PS V:> Get-Host


Name : ConsoleHost
Version : 3.0
InstanceId : 61674c7b-0440-4aea-82c4-db51bf9274f6
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace


also you have to change software to something you are looking for. I Think is the way i copied it to the Powershell studio console. It works now.
This topic is 11 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.