1) How do I create a dynamic array
$a = @()
2) How do I append an element to array
$a += "a"
$a += "b"
3) how do I do a UBOUND on an array
.NET array indexes are zero-based, so ubound is length-1:
$a.length - 1
Friday, May 27, 2011
Monday, May 23, 2011
Powershell - Using IE
Have successfully using Powershell to access IE. Trick to be aware of.
If you launch a web page using "New-Object -comObject InternetExplorer.Application", UAC will block you from accessing the document properties inside. Use the following technique:
& "$env:programfiles\Internet Explorer\iexplore.exe" 'http://powershell.com'
$win = New-Object -comObject Shell.Application
$try = 0
$ie2 = $null
do {
Start-Sleep -milliseconds 500
$ie2 = @($win.windows() ? { $_.locationName -like '*PowerShell*' })[0]
$try ++
if ($try -gt 20) {
Throw "Web Page cannot be opened."
}
} while ($ie2 -eq $null)
$ie2.document
$ie2.Document.body.innerHTML
If you launch a web page using "New-Object -comObject InternetExplorer.Application", UAC will block you from accessing the document properties inside. Use the following technique:
& "$env:programfiles\Internet Explorer\iexplore.exe" 'http://powershell.com'
$win = New-Object -comObject Shell.Application
$try = 0
$ie2 = $null
do {
Start-Sleep -milliseconds 500
$ie2 = @($win.windows() ? { $_.locationName -like '*PowerShell*' })[0]
$try ++
if ($try -gt 20) {
Throw "Web Page cannot be opened."
}
} while ($ie2 -eq $null)
$ie2.document
$ie2.Document.body.innerHTML
Labels:
Powershell IE
Subscribe to:
Posts (Atom)