Problems with PowerCLI script variables
Hello
I hope that someone in the community can tell me where I was wrong in the script below. I have a few other PowerCLI scripts that work in a way similar to this work and these, but this one has a problem. The script is intended to collect information on a number of ESX objects in an array of arrays, $reportfinal, which can then be written to a CSV file that will have the column names for the objects, and each line will yield the values for RDM related objects for each virtual computer. The problem is that, rather than add the results to the table of $reportfinal, the results are crushed, and worse still, the values repeat themselves (for example the size of the various disks is reported as the same value).
$report = @)
$reportfinal = @)
$VMs = get-VMHost | Get - VM | Get-View
$rowcoll = "" | Select the virtual machine, VMController, SCSIBusShare, SCSIBusNumber, SCSIUnitNo, DeviceLabel, SCSISummary, DeviceFilename, DeviceCapKB, DeviceDiskMode, DeviceDiskUUID
{ForEach ($VM to $VMs)
#Clear table report for each virtual computer
$report = @)
Foreach ($SCSI_Controller in ($VM. Config.Hardware.Device | where {$_.} (({DeviceInfo.Label - like "SCSI *"})) {}
$rowcoll. VM = $VM. Name
$rowcoll. VMController = $SCSI_Controller.DeviceInfo.Label
{Foreach ($Disk_Key to $SCSI_Controller.Device)}
Foreach ($Disk_Device in ($VM. Config.Hardware.Device | where {$_.key - eq $Disk_Key})) {}
$rowcoll. SCSIBusShare = $SCSI_Controller.SharedBus
$rowcoll. SCSIBusNumber = $SCSI_Controller.BusNumber
$rowcoll. SCSIUnitNo = $Disk_Device.UnitNumber
$rowcoll. DeviceLabel = $Disk_Device.DeviceInfo.Label
$rowcoll. SCSISummary = $SCSI_Controller.DeviceInfo.Summary
$rowcoll. DeviceFilename = $Disk_Device.Backing.Filename
$rowcoll. DeviceCapKB = $Disk_Device.CapacityInKB
$rowcoll. DeviceDiskMode = $Disk_Device.Backing.DiskMode
$rowcoll. DeviceDiskUUID = $Disk_Device.Backing.UUID
}
}
}
#Append the next line of the report data collection
$report += $rowcoll
#Append the next report to the final report data collection
$reportfinal += $report
}
$reportfinal | Export-Csv-path D:\temp\SAP_Report_Disks_RDM_Mappings.csv - NoTypeInformation
Note: Some parts of the script came another announcement on this forum about a script to display the ROW information for the list of virtual machines.
See you soon,.
Ed
My mistake, I deleted the line wrong $report.
Try this one
$reportfinal = @() $VMs = Get-View -ViewType VirtualMachine foreach ($VM in $VMs) { #Clear report array for each VM foreach ($SCSI_Controller in ($VM.Config.Hardware.Device | where {$_.DeviceInfo.Label -like "SCSI*" } )) { foreach ($Disk_Key in $SCSI_Controller.Device) { foreach ($Disk_Device in ($VM.Config.Hardware.Device | where {$_.key -eq $Disk_Key } )) { $rowcoll = "" | select VM, VMController, SCSIBusShare, SCSIBusNumber, SCSIUnitNo, DeviceLabel, SCSISummary, DeviceFilename, DeviceCapKB, DeviceDiskMode,DeviceDiskUUID $rowcoll.VM = $VM.Name $rowcoll.VMController = $SCSI_Controller.DeviceInfo.Label $rowcoll.SCSIBusShare = $SCSI_Controller.SharedBus $rowcoll.SCSIBusNumber = $SCSI_Controller.BusNumber $rowcoll.SCSIUnitNo = $Disk_Device.UnitNumber $rowcoll.DeviceLabel = $Disk_Device.DeviceInfo.Label $rowcoll.SCSISummary = $SCSI_Controller.DeviceInfo.Summary $rowcoll.DeviceFilename = $Disk_Device.Backing.Filename $rowcoll.DeviceCapKB = $Disk_Device.CapacityInKB $rowcoll.DeviceDiskMode = $Disk_Device.Backing.DiskMode $rowcoll.DeviceDiskUUID = $Disk_Device.Backing.UUID $reportfinal += $rowcoll } } } } $reportfinal | Export-Csv -path C:\SAP_Report_Disks_RDM_Mappings.csv -NoTypeInformation
Tags: VMware
Similar Questions
-
There is a pop up of a problem with the script. He asked end and contuniue the script. I didn't have this problem before. Please help me this is getting really annoying. He asks a lot
I changed a theme and almost never have a problem again...
-
Having a problem with the script error message
The error message and web page script error every move I make now. I tried to check and uncheck boxes tab in advance internet options. I also ran a check of the system that did not help either. Any suggestions? Thank you
Hi Mic,
From the description, it seems that you have a problem with the script error message in Internet Explorer.
To better understand the question, please answer the following questions:
1. is specific to a particular Web site question?
2 have you made changes on the computer before this problem?
3. What is the exact full error message and web page of script error message?
4. When you get exactly the script error message and web page error message appears?
5. what exactly you're talking about when you say "system check"?
See the article mentioned:
How to troubleshoot script errors in Internet Explorer
http://support.Microsoft.com/kb/308260
Hope the above information is helpful. If you have any question back to us, we are happy to help you.
-
Hi, I'm doing a site with dream weaver cs5. I am instituting a slider, this cursor uses java script coding, I'm not familiar with Java script. Here is the site that I have problems with. Www.bussmanncomputers.net/Jara.
What said Teodor, the jQuery library is not found as can be demonstrated when we follow him - http://www.bussmanncomputers.net/Jara/js/jquery.js - link you have placed in your document online.
The only reason why there is a 404 error is because the file is not in the specified location, it has not been downloaded to the location of i.o.w..
-
problems with the script in indesign
Hi all
I'm new and scripts so I hope I can explain what I need
Well, I have an indesign file in which I need to insert an extra layer with the translation of a language, have a layer IN English and an extra a FR for the french.
I found a script that's like that
with (app.clipboardPreferences) {}
pasteRemembersLayers = true;
}
var docTarget = app.documents.itemByName ('French.indd');
var docSource = app.documents.itemByName ('French.indd');
If (docSource.isValid & & docTarget.isValid) {}
var numSpreads = docSource.spreads.length;
for (var i = 0; i < numSpreads; i ++) {}
app.activeDocument = docSource;
app.activeWindow.activeSpread = app.activeDocument.spreads [i];
App.Select (App.activeDocument.spreads [i] .allPageItems);
If (app.selection.length > 0) {}
app. Copy ();
app.activeDocument = docTarget;
If (app.activeDocument.spreads [i] .isValid) {}
app.activeWindow.activeSpread = app.activeDocument.spreads [i];
app.pasteInPlace ();
}
}
}
}
but it seems to cause problems with the files,
I have to say that the source is a file very heavy, even enter takes a long time.
but I want to just get into the text layer,
Do you think this script works finally, can you spot an error or something?
Hello
Your script is copying content of any doc (allPageItems) in an another doc - all number two need to have equal variances.
You don't need to run the script if your goal is to create the new layer in the existing doc.
The questions are
What elements of the page must be copied into this layer
AND
should bound texts copied frames play any content
AND
wherever the content come from?
Jarek
-
Complete the VI Client with PowerCLI Script idle Sessions
Hello gurus PowerCLI
I searched the net for a script PowerCLI that would end all the VI client sessions that have been inactive for x period of time. I found a post on the forums of VMware (http://www.amikkelsen.com/?p=384 , but that one does not work either.
) but had no luck with it. I also found a script created by A.Mikkelsen, toHere's the actual script by A.Mikkelsen that is based on code by LucD in the forum mentioned previously.
BEGINNING
##################################################################################
# The script terminates all sessions if idle idle user for more than xx #.
# #
# Created by: Anders Mikkelsen, 2010 #.
##################################################################################
Claire
# Add - PSSnapin VMware.VimAutomation.Core# $server = "vcenter server.
# $user = "vcenter username.
# $pwd = "password of vcenter.# Add 1 extra hour when, due to the difference of timestamp between MSSQL and Windows.
# slow down time 5 hours = 360
# 10 hours slowed = 660
$intOlderThan = 60# Connect-VIServer $server - user $user-password $pwd
# Connect-VIServer $server$svcRef = new-object VMware.Vim.ManagedObjectReference
$svcRef.Type = 'ServiceInstance.
$svcRef.Value = 'ServiceInstance.
$serviceInstance = get-views $svcRef$sessMgr = get-view $serviceInstance.Content.sessionManager
$oldSessions = @)
{foreach ($sess in $sessMgr.SessionList)}
If (($sess.)) (LastActiveTime) .addminutes ($intOlderThan) - lt (Get-Date)) {}
$oldSessions += $sess. Key
#write "$($sess.)". User name)'
}
}# Session terminal that are inactive for more than approved ($intOlderThan)
$sessMgr.TerminateSession ($oldSessions)Disconnect-VIServer *-confirm: $false
END
The error message I get is:
BEGINNING
Exception calling 'TerminateSession' with '1' or the arguments: "it was not correct to specified parameters.
"
D:\Scripts\vc_terminate_idle_sessions.ps1:36 char: 26
+ $sessMgr.TerminateSession < < < < ($oldSessions)
+ CategoryInfo: NotSpecified: (:)) [], MethodInvocationException)
+ FullyQualifiedErrorId: DotNetMethodException
END
I should mention that my knowledge of PowerCLI is almost nothing, so any help in tweaking this script to make it work with PowerCLI 5.1 Release 2 and VC 5 U2 would be much appreciated.
The error is caused by the fact that you are trying to kill your own session (if it was started long time ago).
Apparently in vSphere 5. they included a security mechanism integrated to avoid this.
You can take this by adding a simple test.
## max number of idle minutes for sessions to keep$intOlderThan = 60$serviceInstance = Get-View 'ServiceInstance'## get the session manager object$sessMgr = Get-View $serviceInstance.Content.sessionManager## array to hold info about stale sessions$oldSessions = @()foreach ($sess in $sessMgr.SessionList){ if (($sess.LastActiveTime).addminutes($intOlderThan) -lt (Get-Date) -and $sess.Key -ne $sessMgr.CurrentSession.Key){ $oldSessions += $sess.Key } ## end if} ## end foreach ## if there are any old sessions, terminate them; else, just write message to the Warning streamif (($oldSessions | Measure-Object).Count -gt 0) { ## Terminate sessions than are idle for longer than approved ($intOlderThan) $sessMgr.TerminateSession($oldSessions)} ## end ifelse {Write-Warning "No sessions that have been idle for more than '$intOlderThan' minutes; no action taken"}
-
Currently I am interested in CS3 & CS2 user, so I doenloaded CS3 but gives the time installation message "Error 1720, there is a problem with this windows package install." A script is required for this installation to complete, contact technical support.
Google search for help with the problem of Windows...
-
Problem with sh scripts on ESXi 5
I recently had to solve some problems with delays during renumerisations and restarts due to RDM which is attached to a host ESXi 5 discs. See this article for details http://kb.vmware.com/selfservice/microsites/search.do?language=en_US & cmd = displayKC & externalId = 1016106. Since I had a large number of RDM disks and needed to run the commands on each host I thought that I would write a script. I created the following scripts (just a subset here), but are there problems when it runs:
Perennial.sh
esxcli storage device base setconfig d naa.60000970000292600424533033434642 - perpetually reserved = true
esxcli storage device base setconfig d naa.60000970000292600424533033434643 - perpetually reserved = true
esxcli storage device base setconfig d naa.60000970000292600424533033443041 - perpetually reserved = true
esxcli storage device base setconfig d naa.60000970000292600424533033443133 - perpetually reserved = trueand
perennial_verify.sh
esxcli storage device base list d naa.60000970000292600424533033434642 > > storage_list.txt
esxcli storage device base list d naa.60000970000292600424533033434643 > > storage_list.txt
esxcli storage device base list d naa.60000970000292600424533033443041 > > storage_list.txt
esxcli storage device base list d naa.60000970000292600424533033443133 > > storage_list.txtI put the files on a data store and gave them execute permissions and they seem to work, however when I run the scripts, they give an error at the end of running something on command not found or something. It does not run all the commands as well. Finally, when the perennial_verify.sh is run more than once something happens in the file storage_list.txt - he had me puzzed for awhile - he showed that the file was different from zero in size, but when I did a cat or less that he would say that the file is not found. Finally I tried to copy the file down in the browser of data store and found that there was a printable character appended to the end - possibly a return carraiage. Now I can not rename the file or delete it - it is impossible to remove. If anyone has any advice on running sh scripts and the correct way to pipe the output to a file I know you more.
Thank you
Ed
What is the exact error do you receive when you try to delete?
Rather than redirect the output for each order, simply redirect the script in the log file, which will capture the entire script.
./perennial_verify.sh > storage_list.txt
-
Problems with the script to output event
In fact I don't know if I have a problem with the Exit event or if there is something wrong with my script syntax... The output of a field event, I check if the field is empty or not and check a flag I put in place.
The first if statement works - if I get back a value in the field, everything goes as planned. If I delete the value of the field, nothing happens.
//if field has a value hide subSection04 if (!(this.rawValue == null || this.rawValue.length == 0)) { subSections.subSection04.presence = "hidden"; } //if field is empty and flag equals true show subSection04 else if ((this.rawValue == null || this.rawValue.length == 0) && (subFlags.Commercial.rawValue == true)) { subSections.subSection04.presence = "visible"; } //if field is empty and flag equals false hide subSection04 else if ((this.rawValue == null || this.rawValue.length == 0) && (subFlags.Commercial.rawValue == false)) { subSections.subSection04.presence = "hidden"; }
There are a few groups radio button that also control this behavior, they are all inter relate. So I tried also triggers the Click event of a radiobutton Group (which resembles the value in this field) out of this area, but that doesn't seem to work.Hi Jono,
Your expression subFlags.Commercial.rawValue is true compares a String data type with a Boolean data type.
Edit the expression as subFlags.Commercial.rawValue is 'true'
I hope that this should work for you.
Your code should look like
//if field has a value hide subSection04 if (!(this.rawValue == null || this.rawValue.length == 0)) { subSections.subSection04.presence = "hidden"; } //if field is empty and flag equals true show subSection04 else if ((this.rawValue == null || this.rawValue.length == 0) && (subFlags.Commercial.rawValue == "true")) { subSections.subSection04.presence = "visible"; } //if field is empty and flag equals false hide subSection04 else if ((this.rawValue == null || this.rawValue.length == 0) && (subFlags.Commercial.rawValue == "false")) { subSections.subSection04.presence = "hidden"; }
Nith
-
Use us SRM and you want to make sure that when done with test that the LVM. EnableResignature is set to return 0 since move us hosts often. I tried 2 different ways to do it and they both fail with "a specified parameter was not correct", all examples I see online are for esx 4.x and below, I didn't know someone check this in 5.x. We are 5.1U1 and latest powercli.
Any help would be greatly appreciated.
Method 1:
$vh contains the name of the host to be reset:
If ((Get-VMHostAdvancedConfiguration - vmhost $vh - name of LVM. EnableResignature). Values - not 0) {}
Game-VMHostAdvancedConfiguration - vmhost $vh - name of LVM. EnableResignature-value 0 - confirm: $false
}
Method 2:
Borrow the code for the functions I've seen online:
If ((Get-VMHostAdvancedConfiguration - vmhost $vh - name of LVM. EnableResignature). Values - not 0) {}
$esx = get-View (Get-VMHost $vh) USER.USER $optmgrMoRef = $esx.configManager.advancedOption $optmgr = get-views $optmgrMoRef $optarray = $optmgr. QueryOptions ("LVM. EnableResignature") $optarray [0]. Value = 0 $optmgr. UpdateOptions ($optarray) }
It seems as if the function of 9 Re: LVM/EnableResignature value = 1 with PowerCLI on ESX 4.1
work on 5.1 as well
Function Set-VMHostResignature {}
[CmdletBinding()]
(Param
[(Setting)
Mandatory = $True,.
ValueFromPipeline = $True
)]
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl []] $VMHost,.
[(Setting)
Mandatory = $True,.
Position = 0
)]
[ValidateSet (0, 1)]
[long] $Value
)
Begin {}
$Option = new-Object Vmware.Vim .optionvalue - property @ {}
Key = "LVM. EnableResignature ".
Value = $Value
}
$OptionArray = $Option
}
{In process
$VMHost | {ForEach-Object
$ESX = get-view $_.ID
$OptMgr = get - see $ESX. ConfigManager.AdvancedOption
$OptMgr.UpdateOptions ($OptionArray)
}
}
}
Get-VMHost | Game-VMHostResignature-value 1
-
All, Hy
I guess it's really simple, but I have no idea how to solve this problem.
The Script looks like this:
"View segment.
(IF (@SUBSTRING (@NAME(&REPORTING_MONTH), 0, 3) = "M07")
'Segment View' = 'Segment View'-> 'real ';
ENDIF ;)
I get the Error Message:
"Error analysis [view Segment] (line xxx) formula: [()] without [)].
Someone at - it an idea how to solve this problem?
Kind regards
Joerg
Published by: Blue Raven on 19.08.2010 02:29Try this. It can works
"View segment.
(IF (@ismbr (@match ('Period', ' M07 * "" ")) and @ismbr (& REPORTING_MONTH)))
'Segment View' = 'Segment of view'-> 'real ';
ENDIF ;) -
Problem with Powershell script for vSpherePowerCLI
Hello
I am creating a script that clones of a VM environment VMware-model as much as I need.
I found a script online, that should do it:
____________________________________
SE connect-VIServer-Server 192.168.0.1
Get-VMHost
$host1 = "192.168.0.2".
$template = 'template1 '.
$datastore = "data1."
$customization = "templtest".
for ($i = 1; $i - 3; $i ++)
{
$tempvm = 'vServer -' + $i
$array += $tempvm
}
foreach ($vm in $array)
{
$vm = New - VM - name $vm - model $template - $host1 - $datastore - OSCustomizationSpec $customization data store host - confirm: $false
}
_____________________________
for example, this script should create 3 Template1 VMs with the names: vServer-1, vServer-2 and vServer3.
But it creates a virtual machine with the name vServer-1vServer-2vServer-3.
Can someone help me with this problem?
Is there something wrong in education for?
Thanks in anticipation,
Alex
Hi Alex,
Before the statement, you must insert the following line:
$array = @()
This will initialize the variable $array as an empty array.
Best regards, Robert
Post edited by: RvdNieuwendijk
-
Problem with Java Script in my mail service
I'm unable to access my email GMX account. Whenever I try, a rose windows opens at the top indicating that Java Script is required. However, when I check with the tolls, the enable JavaScript box is checked. I've deleted and reinstalled Firefox 10.0.1 two times with the same results. I can to my account via Internet Explorer and Safari without difficulty.
Any ideas?
Due to various difficulties, I reinstalled Windows 7. That solved the problem
-
Problem with external scripts to run
Hello
I was wondering if someone can help me, got a problem where the external script is running without problems, the file gets generated and released into the log folder then file disappears as expected.
When the file disappears, file does not appear to have sent to the BB server. The file has no file extension.
The customer is 4.40 and the host file is defined by:
"IP ADDRESS" "Servername" #testip "filename."
I expect that filename must display the column in Big Brother, but does not...
All thoughts.
Concerning
Col
What is the format that you use for the log file?
help of BBPE customer win:
The first line must begin with the color of the State for the test (usually green, yellow or red). The rest of the file can contain anything; If you click on the color on the screen of Big Brother, you will see the contents of the file. Generally, we recommend that include you the date, time and name of the host on the first line, with the following lines describing the results of the tests, like this:
color day date [hostname]
results message
results message
...For example:
Red game 08 21:10:24 1998 [xxx.domain.com]
blah blah
blah blahWe highly recommend that you include the host name on the first line, especially if the client computer uses the DHCP protocol.
You can change the amount of time before the test results never expire (and the test status shows purple), the substitution of the default on the servers of the display. Place a sign plus (+) and the time, before immediately after the color in the log file. You can express the time in minutes (m), hours (h) or days (d). For example, to have this test does not turn purple for 26 hours:
Green + 26: Thu 08 21:10:24 1998 [xxx.domain.com]
blah blah
blah blahChange the expiration time can be useful for scripts that you run only once a day: save the controls, the system checks every day and so on.
In addition, you can send the status for a test on a different host including the hostname before color, separated by a colon (:). This is useful if you run tests for several hosts from the same client of Big Brother. For example:
Some.Host.Anywhere:Red Thu 08 21:10:24 1998 [xxx.domain.com]
blah blah
blah blahThis indicates to the server that this status is for some.host.anywhere, not for the current client host.
-
Problem with PL/SQL variables...
Hi, I am fairly new to this, so apologies if this is a simple question.
I have a text field on my page (ENTITY_ACC_NO), and I'm putting a pl/sql block on it to fill with a conditional piece of treatment based on the value of another field (ENTITY_SELECT). (Its actually a drop-down list)
So on the source of the article, I updated the source type the body of the pl/sql function with the following code piece...
IF: ENTITY_SELECT = '%' THEN
: ENTITY_ACC_NO: = ";
ON THE OTHER
Select account_no in: entity_acc_no of the entity where entity_id =: entity_select;
END IF;
The problem is that it does nothing... Firstly, I correctly use variables? I read somewhere that you should use the function of V, but it also seems like you use this for stored procedures, rather than a simple pl/sql.
Either way, im actually trying to work around the error as the drop-down list has '%' in it for another database query text, and I use it here through its primary key to retrieve other information about this...
Thank you very much
Richard
Source of the element is used when rendering a page - looks like you can expect as things change when a selection list option is specified.
Discover the use of dynamic actions
http://www.grassroots-Oracle.com/2013/10/Apex-101-dynamic-actions.html
The other thing that I can see is the page elements, you specify is not a page number of prefix, which is worth questioning - you specify the name and why you use the conventional notation P1_ITEM_NAME?
Maybe you are looking for
-
XControl always locked when it is used in class - possible bug?
Hello It is no different in this issue. However, I think the question is slightly different and maybe a bug. If the following steps: Create a project, create an XControl create a class, Add an instance of the XControl to a class method You should see
-
First HP screen, then a black screen with a flashing underscore
Hello! I bought a new graphics (Asus GeForce GT 740 PhysX CUDA 2 GB) card for my desktop PC (HP Pavilion p6-2067sc) and have a problem. When I put in the card and start the PC the HP screen sometimes maybe 20 seconds and after that it's a black scree
-
(Redirected) Real-time clock error
My laptop is a dell inspiron 17-7737 a few times when I unplug my cell phone by USB, the laptop turns off and restarts with a real time clock error message. What is the cause of this and how this can be solved I use windows 8.1
-
BlackBerry Bond can synchronize select only Facebook contacts?
HeyIs there a possibility to synchronize only contacts in facebook with my phone contacts? MOD EDIT: Subject changed to reflect a new topic
-
problems with running BB10 Soft on desktop
Hello I have correctly installed the SDK of BB10 on Flashbuilder 4.6 and I am able to run the HelloWorld application. It runs correctly on the device (Dev Alpha), but when I run the application on the desktop (not on the Simulator), the police of the