nesher13
asked on
option "reset runspase" (?) in PowerGui causes script error
I uploaded in PowerGui editor script that I debugged Up to this time in it, and it worked.
At some point I have done in the editor option "reset runspase". and thereafter
script stopped working and I'm getting many error messages:
What do I have to make the script work again
At some point I have done in the editor option "reset runspase". and thereafter
script stopped working and I'm getting many error messages:
Get-WmiObject: Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Supply an argument that is not null o
r empty and then try the command again.
At C: \ Powershell \ Scripts \ Change3.ps1: 7 char: 62
+ $ ObjCompSys = Get-WmIObject-class "Win32_ComputerSystem"-cn <<<< $ machine-EA silentlyContinue-namespace "root \ CIMV2"
+ CategoryInfo: InvalidData: (:) [Get-WmiObject], ParameterBindingValidationException
+ FullyQualifiedErrorId: ParameterArgumentValidationError, Microsoft.PowerShell.Commands.GetWmiObjectCommand
quote the full text of the script:$Machine = Get-Content -Path C:\powershell\scripts\Computers.txt
$AllComputers = @()
foreach ($Machine in $Machines)
{
$objCompSys = Get-WmIObject -class "Win32_ComputerSystem" -cn $machine -EA silentlyContinue -namespace "root\CIMV2"
$compname = $objCompSys.Name
$physicalRAM = [Math]::Ceiling($objCompSys.TotalPhysicalMemory / 1GB)
$CurrentUser = $objCompSys.username
$Motherboard = $objCompSys.Model
$objCompOS = Get-WmIObject -class "Win32_OperatingSystem" -cn $machine -EA silentlyContinue -namespace "root\CIMV2"
$WindowsVersion = $objCompOS.Caption
$ServicePack = $objCompOS.csdversion
$WinInsDate = $objCompOS.ConvertToDateTime($objCompOS.InstallDate) | Get-Date -Format d
$DiskItems = Get-WMIObject -Class Win32_DiskDrive -Filter {DeviceId = '\\\\.\\PHYSICALDRIVE0'} -comp $machine | select -ExpandProperty size
$DiskSize = $DiskItems/1GB
$NetAdapters = Get-WmIObject -class "Win32_NetworkAdapterConfiguration" -cn $machine | where{$_.IPEnabled -eq "True"}
$IPAddress = foreach($Adapter in $Netadapters){$adapter.ipaddress}
$objProc = Get-WMIObject -class "Win32_Processor" -cn $machine
$procType = $objProc.Name
$Object = New-Object PSObject -Property @{
CompName = $compname
WindowsVersion = $WindowsVersion
ServicePack = $ServicePack
WinInsDate = $WinInsDate
IPAddress = $IPAddress
CurrentUser = $CurrentUser
Motherboard = $Motherboard
ProcType = $procType
DiskSize = $DiskSize
MemoryCapacity = $physicalRAM
}
$AllComputers += $Object
}
$AllComputers | select CompName,IPaddress,WindowsVersion,ServicePack,WinInsDate,CurrentUser,ProcType,Motherboard,DiskSize,MemoryCapacity | Export-Csv c:\Powershell\change5.csv -NoTypeInformation
I have checked the file on the computer that there are gaps at the end of lines and did not find them.What do I have to make the script work again
ASKER
to sedgwick,
it did not solve my problem
it did not solve my problem
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please note that "da rulez" say that a precise and complete answer should receive a grade of "A". The answer was spot on, nothing more to add on value, and nothing really obvious, so I would expect "A" here. Is there any reason for the "B"?
http://dmitrysotnikov.files.wordpress.com/2011/08/scripteditor-resetrunspaceondemand.png