| Topic |
 |
RE: passing comand options to an installer Try using Start-Process: $file = "\\server\public\Windows\application_setup.exe" $arguments = "/VERYSILENT /LOADINF=\\server\public\Windows\Setup.ini" Start-Process -FilePath $file -ArgumentList $arguments -Wait by George Howarth in General PowerShell on 22 Sep 2010 12:03 PM
|
 |
RE: Determining which absolute element in an array you are working with You can use a for loop: $lines = Get-Content -Path "MyFile.txt" for ($i = 0; $i -lt $lines.Length; $i++){ Write-Host "Reading element $i ..." Write-Host $lines[$i]}Generally, use a for loop if you want to keep track of where you are in ... by George Howarth in General PowerShell on 21 Sep 2010 11:52 AM
|
 |
RE: Script that runs commands for all computers listed on spreadsheet Can't test, but try this:$excel = New-Object -ComObject Excel.Application $excel.Visible = $true $workBook = $excel.Workbooks.Open("C:\Scripts\intachlist.xls")$workSheet = $workBook.Worksheets.Item(1) $i = 1 do { $computerName = $workSheet.Cells. ... by George Howarth in Peer Review on 20 Sep 2010 03:37 PM
|
 |
RE: FindRegistrySetting.ps1 There is an error with the way you are using Test-Connection. Change it to this:foreach ($Computer in $Computers){ #Ping each server to check that it's alive $success = Test-Connection -ComputerName $Computer -Quiet -Count 1 if ($succes ... by George Howarth in Peer Review on 20 Sep 2010 03:27 PM
|
 |
RE: formatting data into excel powershell Export-CSV is for CSV files and you can open those file types with Excel. If you want to go straight from raw CSV data to an Excel spreadsheet then that is an entirely different ball game altogether. For example (taken from http://poshtips.com/2009/ ... by George Howarth in General PowerShell on 20 Sep 2010 03:18 PM
|
 |
RE: Gridview Help I'm assuming that you're only interested in the services that are declared in array. If so, try this, you just need to edit the last line to output an XML file:trap [Exception]{ Write-Error -Message ("TRAPPED: " + $_.Exception.Message)} $log ... by George Howarth in General PowerShell on 20 Sep 2010 02:55 PM
|
 |
RE: Conditional menu -- Did I do this right? I altered it slightly (left some comments in):$a = @('*.bat', '*.txt')$b = Get-ChildItem -Filter $a # Try naming functions in the format 'Verb-Noun' as this will keep it consistent with existing PowerShell naming conventionsfunction Delete-Items{ ... by George Howarth in General PowerShell on 20 Sep 2010 02:18 PM
|
 |
RE: Print a .bmp file? Try this instead. I think this works (this stupid XPS software keeps giving me a dialog...):function Print-Bitmap{ param ( [System.Drawing.Bitmap]$Bitmap ) $printDocument = New-Object System.Drawing.Printing.PrintDocument ... by George Howarth in General PowerShell on 20 Sep 2010 02:07 PM
|
 |
RE: Print a .bmp file? The second paramter is not optional. You have the following options: 0 = Carry out the default operation 1 = Prompt the user 2 = Don't prompt the user 3 = Show help by George Howarth in General PowerShell on 17 Sep 2010 03:13 PM
|
 |
RE: using -replace or [regex]::replace to replace substring but using other data to match first Try this:$before = "01/29/2010 9:32:22.196 168 99.99999234234 99.34234324234234 95.23123324234324 47.321999230984" $regex = '(?\d{1,2}/\d{1,2}/\d{1,4})\s(?\d{1,2}:\d{1,2}:\d{1,2}\.\d+)\s(?.*)' # remove the spaces in the angle brackets if ($before -m ... by George Howarth in General PowerShell on 17 Sep 2010 06:39 AM
|
 |
RE: Print a .bmp file? There is no Print() method on the InternetExplorer object, it seems that you have to use the ExecWB() method and provide enumeration values to specify the operation you want IE to carry out. Try this: $ie = New-Object -ComObject InternetExplorer. ... by George Howarth in General PowerShell on 17 Sep 2010 06:14 AM
|
 |
RE: Bulk renaming fotos from Name_Firstname to username Can you give us an sample of what the CSV looks like? Sounds pretty easy to do. All you would need to do is setup a hashtable and then rename accordingly as you loop through the image files. by George Howarth in General PowerShell on 17 Sep 2010 05:59 AM
|
 |
RE: Do Unil loop question Try this:function Read-ConsoleOutput{ param ( [System.Diagnostics.Process]$Process, [String]$Command, [Int32]$Timeout ) $Process.StandardInput.WriteLine($Command) $output = Wait-Prompt -P ... by George Howarth in General PowerShell on 07 Aug 2010 02:07 AM
|
 |
RE: Hash Table to Export-CSV Better way, but haven't tested:function New-Template{ param ( [System.Collections.HashTable]$HashTable ) $obj = New-Object PSObject $HashTable.Keys | ForEach-Object { $obj | Add-Member -MemberType NoteProperty -Nam ... by George Howarth in General PowerShell on 06 Aug 2010 11:41 AM
|
 |
RE: Hash Table to Export-CSV Extremely ugly and ungeneric, but I think its something to start with:function New-Row{ param ( [String]$ADGroup1Member, [String]$ExGroup1Member, [String]$ADGroup2Member, [String]$ExGrou ... by George Howarth in General PowerShell on 06 Aug 2010 05:08 AM
|
 |
RE: Hash Table to Export-CSV To be honest, after reading your post again, what you're trying to do here doesn't really make sense. The columns in a CSV or any data structure that models itself after a database table is supposed to define the structure of a row. This would be th ... by George Howarth in General PowerShell on 05 Aug 2010 01:15 PM
|
 |
RE: Converting a txt file to a table $people = @() $data = Get-Content -Path "file.txt" for ($i = 0; $i -lt $data.Length; $i += 3){ $name = ($data[$i] -split '=')[1] $address = ($data[$i + 1] -split '=')[1] $number = ($data[$i + 2] -spli ... by George Howarth in General PowerShell on 04 Aug 2010 02:13 AM
|
 |
RE: executing a power shell script from SSh You need to post your script. Sounds like you need to use a different encryption key when running the script with SSH. by George Howarth in General PowerShell on 03 Aug 2010 01:18 PM
|
 |
RE: Converting a txt file to a table function ConvertTo-Object{ param ( [String]$Person ) $objPerson = New-Object PSObject $Person.Trim() -split ' ' | ForEach-Object { $objPerson | Add-Member -MemberType NoteProperty -Name ($_ -split '=')[0 ... by George Howarth in General PowerShell on 03 Aug 2010 01:11 PM
|
 |
RE: Hash Table to Export-CSV Hmmm yes I had a feeling that might happen. What is the output you are expecting? by George Howarth in General PowerShell on 03 Aug 2010 12:39 PM
|
 |
RE: How to remove certain lines in text files? Try this (make sure you test it on just one file first :) ): $path = "file.txt" $lines = Get-Content -Path $path 1..4 | ForEach-Object { $lines[$_] = $null } Set-Content -Path $path -Value $lines by George Howarth in General PowerShell on 02 Aug 2010 01:41 PM
|
 |
RE: Trouble with get-eventlog cmdlet The Before and After parameters accept DateTime values, not String values like you are trying to pass in.$data = @() $culture = New-Object System.Globalization.CultureInfo -ArgumentList "en-US"$before = [DateTime]::Parse('07-31-2010 01:00:00 ... by George Howarth in General PowerShell on 02 Aug 2010 01:27 PM
|
 |
RE: Hash Table to Export-CSV Yeah, I think using a custom object is the way to go here. I haven't tested, but try this (insert after your existing code): $DistroList.GetEnumerator() | ForEach-Object { New-Object PSObject -Property @{ Group = $_.Key; Members = $_.Value } | Se ... by George Howarth in General PowerShell on 02 Aug 2010 08:20 AM
|
 |
RE: working with data table and variable 1. I updated the script so that it accepts a path to a CSV file. The script assumes that the CSV file is in the format: Server, InstancesomeServer, someInstance2. I'm not exactly sure what you mean when you say "same output". If you mean that you do ... by George Howarth in SQL Server on 02 Aug 2010 03:13 AM
|
 |
RE: working with data table and variable Fire away. by George Howarth in SQL Server on 30 Jul 2010 02:48 AM
|
 |
RE: working with data table and variable Try this: $server = "Server1"$instance = "PPP" $dataTable = Get-OLEDBData -Server $server -Instance $instance $dataTable.Rows | ForEach-Object { if ($_["USED_PERCENT"] -gt 30) { Write-host ("Table Space Name {0} is cross ... by George Howarth in SQL Server on 29 Jul 2010 04:17 AM
|
 |
RE: Variable conversion from import-csv not converting to.. variable To be exact, it wasn't being ignored, the value just wasn't being evaluated against anything, so therefore the default value of false was returned. by George Howarth in General PowerShell on 28 Jul 2010 12:08 AM
|
 |
RE: Win32_Processor Xeon What does this give you?[Environment]::GetEnvironmentVariable("PROCESSOR_ARCHITECTURE", [EnvironmentVariableTarget]::Machine) by George Howarth in General PowerShell on 27 Jul 2010 11:08 AM
|
 |
RE: Variable conversion from import-csv not converting to.. variable Ohhhhhh I get you now, you're trying to use SharePointFilters as a predicate.$stores = Import-CSV -Path C:\Temp\Stores.csv$distroGroups = Import-CSV -Path C:\Temp\DistroGroups.csv$distroGroups | ForEach-Object { $spFilter = $_.SharePointFilters ... by George Howarth in General PowerShell on 27 Jul 2010 07:13 AM
|
 |
RE: Variable conversion from import-csv not converting to.. variable I don't think this is correct: GroupNames,SharePointFiltersStores ALL, ($_.'Banner Type_ID.Name' -eq 'Diegos' -and $_.'Banner_ID.Name' -eq 'Bannered')I managed to get this far:$stores = Import-CSV -Path "$SPWork\Stores.csv"$distroGroups = Import-CSV ... by George Howarth in General PowerShell on 27 Jul 2010 02:05 AM
|