get-qadcomputer - taking too much memory - is it a code issue ?

gc c:\machines.txt | get-qadcomputer| foreach {


 $computer = $_.name
 $computer

 $ou = $_.parentcontainerdn -match "^ou=(.+),ou=(.+),dc=powershell,dc=com$"
 $actual_ou = $matches[2]


 # write to file #
 $a = "$computer `t $actual_ou"
 $a | out-file -filepath $Summarypath -append


 # remove variable #

  remove-variable ou
    remove-variable actual_ou
 remove-variable a
 remove-variable computer
 [GC]::Collect()


}


0
IT
4/30/2010 2:35:19 AM
windows.powershell 690 articles. 0 followers. Follow

4 Replies
1383 Views

Similar Articles

[PageSpeed] 37

Try this:

gc c:\machines.txt | get-qadcomputer | select name,@{n='OU';e={$_.ParentContainer.split("/")[1]} 
| export-csv $Summarypath 





---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar
Twitter: http://twitter.com/ShayLevy



IS> gc c:\machines.txt | get-qadcomputer| foreach {
IS> 
IS> $computer = $_.name
IS> $computer
IS> $ou = $_.parentcontainerdn -match
IS> "^ou=(.+),ou=(.+),dc=powershell,dc=com$"
IS> $actual_ou = $matches[2]
IS> # write to file #
IS> $a = "$computer `t $actual_ou"
IS> $a | out-file -filepath $Summarypath -append
IS> # remove variable #
IS> 
IS> remove-variable ou
IS> remove-variable actual_ou
IS> remove-variable a
IS> remove-variable computer
IS> [GC]::Collect()
IS> }
IS> 


0
Shay
5/1/2010 8:38:24 PM
Allow me to add a missing closing brace

   gc c:\machines.txt | get-qadcomputer | select
   name,@{n='OU';e={$_.ParentContainer.split("/")[1]}} | export-csv
   $Summarypath

- Larry

On 5/1/2010 3:38 PM, Shay Levy [MVP] wrote:
> Try this:
>
> gc c:\machines.txt | get-qadcomputer | select
> name,@{n='OU';e={$_.ParentContainer.split("/")[1]} | export-csv
> $Summarypath
>
> ---
> Shay Levy
> Windows PowerShell MVP
> http://blogs.microsoft.co.il/blogs/ScriptFanatic
> PowerShell Toolbar: http://tinyurl.com/PSToolbar
> Twitter: http://twitter.com/ShayLevy
>
> IS> gc c:\machines.txt | get-qadcomputer| foreach {
> IS> IS> $computer = $_.name
> IS> $computer
> IS> $ou = $_.parentcontainerdn -match
> IS> "^ou=(.+),ou=(.+),dc=powershell,dc=com$"
> IS> $actual_ou = $matches[2]
> IS> # write to file #
> IS> $a = "$computer `t $actual_ou"
> IS> $a | out-file -filepath $Summarypath -append
> IS> # remove variable #
> IS> IS> remove-variable ou
> IS> remove-variable actual_ou
> IS> remove-variable a
> IS> remove-variable computer
> IS> [GC]::Collect()
> IS> }
> IS>
>
0
Larry__Weiss
5/1/2010 9:13:56 PM
May i know this expression what it means ?

$_.ParentContainer.split("/")[1]}} 

How do u interpret the number 1 ?
0
IT
5/2/2010 3:56:10 AM
Consider

   PS C:> ('aaa/bbbb/cccc/dddd').split("/")[1]
   bbbb

the 1 is the index (0 based) into the array created by the split() method.

I don't have experience with   get-qadcomputer   so I can't be specific
as to how that string parsing technique applies in that context to the
associated ParentContainer property (presumably a string with / characters
in it).

  - Larry


IT STAFF wrote:
 > May i know this expression what it means ?
 >
 > $_.ParentContainer.split("/")[1]}}
 > How do u interpret the number 1 ?
0
Larry__Weiss
5/2/2010 3:31:55 PM
Reply:

Similar Artilces:

Issue with Stock Options in Conversion from 2004 to 2005
In my 2004 standard version I have 5 stock option grants. After conversion to 2005 standard not all the grants show up in the Portfolio Manager. In Portfolio Manager only the first 3 grants show up. In the Portfolio Review the 1st, 4th and 5th grants show up. In the Stock Options Account Register, all the grants and transaction are showing. Seems to be a bug. Any ideas on how to get all the grants in all the views? I have a simular issue. All 4 of my stock options grants showed up when converting to 2005. After exercising part of one of the grants, that grant no longer shows up in th...

code to delete vba code
I hve found this code to delete all code within a workbook. As soon the code reach the line If "ThisWorkbook.VBProject.Protection Then Exit Sub" the code stop and a failure message appear "if without end if " could you please help me with this issue. Thanks Sub ClearThisWorkbookCode() Dim StartLine As Long, LineCount As Long If ThisWorkbook.VBProject.Protection Then Exit Sub On Error Resume Next With ActiveWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule StartLine = .ProcStartLine("Workbook_Open", 0) If Sta...

Number format issue Access 2007
Access 2007. I've created a database with a number input and I'm getting the following errors. I've formatted a field as Number Field Size: Single Format: Currency Decimal Places: 0 I'm getting the following results Input 2,065,000,000 but it's rounding it to 2,064,999,936 Input 2,682,000,000 but getting rounded to 2,681,999,872 Any ideas on the reason for this? Do I have that field formatted properly? You help is GREATLY appreciated! (B^>)-]=[ Single is a floating point type. Accuracy is only 7 or 8 significant digits. More info: ...

i get error 404 not found when trying to download
I'm trying to download nokia pc suite to windows xp to upload gallery onto the computer but get error message404 not found - how can i download this pc suite please -- Krysy Albutt Krysy Albutt wrote: > I'm trying to download nokia pc suite to windows xp to upload gallery > onto the computer but get error message404 not found - how can i > download this pc suite please Care to enlighten us how this pertains to: - 1) Microsoft 2) Publisher 3) Windows If you're having problems downloading from the *NOKIA* site where do you think you should be directing your ...

How to get Calendar to send me reminders
I have changed my e-mail address but for some reason I cannot get Calendar to send reminders to my new address - I think I have carried out all that is necessary to effect the changover but I am not getting reminders sent. Can anyone help please? Is the Calendar Live ID based and accessible at Calendar.live.com ? -- ....winston ms-mvp mail "Dabardevon" wrote in message = news:FDC2B3B2-EDE4-41B1-BFC4-C0F9ED59CFB9@microsoft.com... I have changed my e-mail address but for some reason I cannot get = Calendar to send reminders to my new address - I think I have...

Some recipients get the attachment, some get winmail.dat
This one has me baffled. We are using Exchange 2000 and Outlook 2000 and have been for 8 months. No previous problems with attachments (.doc, .xls, .jpg). About 2 weeks ago, we started hearing from certain recipients that the attachment wasn't arriving; instead they were getting an unreadable file called winmail.dat. MS says that this is because the sender is using Rich Text to format the email. We have changed the senders to use Plain Text and still have the same problem. If the email is sent to several recipients, some will get the attachment fine, some will not. This didn'...

Running code when hyperlink clicked
Hello, I am definitely baffled. I am trying to run code when a hyperlink is clicked. I am using Excel 2007, the hyperlink is created in a cell on Sheet 1 using "=hyperlink()", the hyperlink is to a video clip, and events are definitely enabled. I had tried two things, either of which would be fine: 1. I put the following code in Sheet1, and it did not respond at all. What am I doing wrong? Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) Sheets("Sheet1").Range("B1") = "It Ran" End Sub 2. I put the following...

A Crystal Beginner
I am using Crystal 9.2.4.77 and have loaded the Crystal enhancements. Now I want to do against the CRM database. What do I do? I thought I would create a data source to the CRM SQLserver, which I did, then connect to it through Crystal Reports. That works, but when I drill down on the AAA_MSCRM database to choose my tables, it shows me dbo as the only option (where did this come from??) and under that are just a few generic tables. No CRM tables. Something's not quite right. What am I missing? file - log on to aps server "KBLawson" <klawson@aetinc.com> wrote in ...

Estimating memory usage per worksheet
Is it possible to get an estimate of the file size of a spreadsheet by individual worksheet? I cannot think of a worksheet property that would contain this, so I assume that one needs to count sheet elements and apply a per-object memory value (this only needs to be an estimate) to get the estimat. Any help would, as always, be much appreciated Thanks in advance Simon I'd try this. Start a new workbook -- with just a single sheet. Save this workbook. Note the size (using windows explorer). Then against a copy of the real workbook (just in case you mess up), c...

Dexterity
When clicking on a lookup icon under debug mode, I receive the following message: "Cannot access this form because the dictionary containing it is not loaded." If anyone knows how to fix this issue, please let me know. Thanks, Pat When use lookup buttons in GPlains, GPlain open smart list window. in test mode you wouldn't have access to smart list. in Great Plains, take off those alternative windows under security, depends on which module you are working on, only take off smart list alternative window on that module will be ok. hlv is correct. The Lookups you see whe...

How to get the CScrollBar's Handle in CTreeCtrl?
Hey,All: I thought I have a problem when I trid to get the CScrollBar's handle from my CTreeCtrl extended handle. Can anybody tell me whether I can get the handle of the CScrollBar from the CTreeCtrl? Thanks in advance! Carl :-| Carl wrote: > Hey,All: > > I thought I have a problem when I trid to get the CScrollBar's handle from > my CTreeCtrl extended handle. > Can anybody tell me whether I can get the handle of the CScrollBar from the > CTreeCtrl? > > Thanks in advance! > Carl > :-| > > Sorry, it is not that simple. The scroll bars that...

Cannot get fast forward or fast reverse to work with WMP 11
I am running Vista Home Premium on a HP G 217-EM Notebook which comes pre-installed with Windows Media Player 11. When I play cds and try to fast forward or fast reverse by keeping the fast forward or fast reverse buttons constantly depressed nothing happens. Why is this, and can anyone come up with a solution? Many thanks This doesn't work on my system either, so it's probably just a limitation of WMP. Fast forward and fast reverse should work fine when you rip the CD's to MP3 or WMA files, and play these files instead. Regards -- Tim De Baets http://www....

Printing Issue #3
I am trying to make an invitation using publisher 2003. I am required to use a couple of photo's I have got of the school's website but they don't print. Normal clip art images will print but my pictures of the internet won't. I have tried saving them to the computer then using them and also copying and pasting and neither works. I also thought it might be because they were from the net so I used the orignals of a cd and it still did not print. They are being used as an image behind text but even without text over the top they still fail to print. The advance print...

Get paid while you get online!!
I found a great Internet company - Cashfiesta.com - that has created a product everyone can benefit from. They pay you while you work or play on your computer. All you need to do is keep their software - the FiestaBar=99 - active while you are online. They even pay you when your friends are using their computers. Unlike other companies, Cashfiesta gives you control over how much money you earn. They have an individual payrate based on the number of Special Offers you sign up for. As some of these offers are free, you can increase your payrate up to 33 times without spending a penny. It's...

Can't get auto-update (update) to install
Version: 2008 Operating System: Mac OS X 10.4 (Tiger) Processor: Power PC I've been trying to manually check for updates to Word 2008, and I get a &quot;critical update&quot; notice, asking me to install auto-update. When I try to install it, I cannot. It just keeps repeating the attempt, in an &quot;endless loop.&quot; What to do? <br> Thank you. ...

Spreadsheet getting corrupted
Hello All: I have a relatively large spreadsheet. I am getting errors (see after my signature line). What could be causing these errors? Is it that the spreadsheet is too large? Thanks Deguza -------------------------------------------------------- Microsoft Office Excel File Repair Log Errors were detected in file 'C:\Documents and Settings\deguza\My Documents\sales\Sales_2006_2007.xls' The following is a list of repairs: Global PivotTable report information was repaired due to integrity problems. Global PivotTable report information was repaired due to integrity problems. Glo...

Major startup issue
I have had my vista home premium system for a little over a year with no real issues. The other day I did a system restart . The manufactures logo which normally comes up for about 20 seconds before moving on to the microsoft welcome screen stayed on for at least 5 minutes and then the screen went black for a couple of minutes. Then a short blinking cursor with a message that "Bios not installed!", then black for several minutes and then a message that the pc could not start and I was prompted to select an option for automatic repair. I did so and after about 10 min...

Intersting issue regarding msg files
I have a client using Outlook 2003. Scenario: 1. Client creates a message (default format is HTML) and saves it as a draft. 2. Client then drags and drops message from draft folder into a network location. File has .msg extension. 3. Another user then double clicks on the msg file, and makes some live changes to it and then clicks SEND 4. Message is sent but none of the changes were made. The client used to do this with Outlook Express and never had a problem. Now that they are using Outlook 2003 this problem has surfaced. Any ideas? TIA KIWI ...

Reg getting the next IV Document Number field !
Hi, I am creating a window in dexterity similar to the item transaction entry window (Transactions>Inventory> Transaction Entry). In the Item transaction Entry window, the Document number field defaults to the next document number when we move the focus to that field. I wanted to know if there is any function , or table that i can access to get the next document number in the new window that i am creating. Thanks, swetha -- swetha >In the Item transaction Entry window, the Document number field defaults to the next document number when we move the focus to that field.< T...

How do I get??
Sorry if this seems a fairly easy question to you guys. I have a spreadsheet and I need to get the current system time into a cell. The format of the time is hh:mm am/pm. Any assistance would be most helpful. Hi try =INT(NOW()) in this cell and format is to your needs -- Regards Frank Kabel Frankfurt, Germany PM wrote: > Sorry if this seems a fairly easy question to you guys. > > I have a spreadsheet and I need to get the current system time into a > cell. The format of the time is hh:mm am/pm. > > Any assistance would be most helpful. PM, in the cell you want pu...

Get notified when Out of Office is on
I am using Outlook 2007. With 2003, when returning from leave, I used to get a notification that the Outlook out of office was still on and asking me if I wanted to switch it off. This reminder no longer appears with 2007. How can I switch this setting on so that I get the notification? "Mary Ann" <MaryAnn@discussions.microsoft.com> wrote in message news:ED5533A7-D0EA-41B8-B1A0-A9D15FB6FD98@microsoft.com... >I am using Outlook 2007. With 2003, when returning from leave, I used to get > a notification that the Outlook out of office was still on and asking me ...

Getting Control ID in Active X control
GetWindowLong return 0. You need to call GetDlgCtrlID from outside the activex control as the function available within the control returns an arbitrary value of zero. Take a look at this article http://xendra.ens.uabc.mx/~sinfante/loo/libro/ch17_4.htm particularly the paragraph preceeding the title "MFC and Ambient Properties". This really begs the question why you want the ID in the first place as activex controls have to be fully self containing to operate - with a few exceptions where sibling controls need to be able to locate each other. - Tim "ytv" <...

over VPN, it gets stuck when sending outgoing email
When I use VPN to connect to work from home, the outlook can not finish sending outgoing emails. The progress bar moves to the end but then stops there forever. It can never finish. The receiving of new incoming emails work fine. All other network functionality works, e.g. internet browsing, telnet, ftp, etc, all work fine. My system is win2k. I use linksys wireless DSL router. I'd appreciate any hint! Are you using Exchange server? I'd set up your mail profile to prompt you to work offline or online - when using VPN, work offline with scheduled syncs. If not using exchange, pos...

Get photos from a camera
I have an asp.net intranet application that I need to upload 1 or all photos from a digital camera at a PC workstation. We are using DataGrids and GridViews to display them on the web once they are uploaded but need something at the client. I assume I need some sort of ActiveX process or something. Has anyone run into a solution for this need? Thanks. -- David "DavidC" <dlchase@lifetimeinc.com> wrote in message news:2B061F4F-B548-4AA4-96FA-2F87383192D2@microsoft.com... > I have an asp.net intranet application that I need to upload 1 or all > photos ...

XML discount print issue
Hi all, I have a issue with printing discounts on receipts. First of all, I did a lot of RMS XML programming for customers, so I think I know what i'm talking about. But I cannot figure out the following: The price and extended price printed on receipts are the actual prices customers have to pay. Now I have one customer who wanted to always print the full price on each line, without the discounts instead of the discounted price. That can easily be done by changing the Entry.Price to Entry.FullPrice. So far so good. But, now they want also the following. If they change a price at...