Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. crobin1

    Start-Process from array value with arguments

    I haven't tried this myself, but looking at the help the following seems to be the issue. Start-Process expects the program to run (the -FilePath parameter) to be just the program and nothing else. There is a separate parameter to Start-Process, -ArgumentList, which can be used to pass...
  2. crobin1

    How to do this in PowerShell

    Maybe this could help: http://jdhitsolutions.com/blog/2012/01/convert-text-to-object-updated/
  3. crobin1

    How to do this in PowerShell

    There's also a -Split operator that can do simple matches as well as regexp. See http://technet.microsoft.com/en-us/library/dd347708.aspx or http://tasteofpowershell.blogspot.com/2009/08/string-manipulation-splitting-and.html for some possibilities.
  4. crobin1

    Find and Replace

    I think the problem is your $configFiles=get-childitem... line. The Out-File cmdlet is an "end-of-line" cmdlet, it produces the file but doesn't pass along any objects through the pipeline. I think if you examine $configFiles after that statement you'll find it either empty or actually null...
  5. crobin1

    How to do this in PowerShell

    PowerShell actually has a native command for getting process information, Get-Process. Since it returns objects, it's a little easier to work with than parsing the strings. For things that don't have native PowerShell equivalents, there are commands such as Select-String for the equivalent of...
  6. crobin1

    Cmdlet parameter from variable

    I think what you want to use is what is known as splatting. I haven't tried it, but start with this "Hey, Scripting Guy!" article (and there's a link to other articles about splatting)...
  7. crobin1

    Exporting Results To File

    Wotsit, I ran your script exactly as shown in your second post and it worked just fine for me. Did you run it exactly (same directory, same files, same account with permissions to access remote registry) as before?
  8. crobin1

    Exporting Results To File

    Here's one way to do it. The extra variable $outstring helps keep the output to one line for each entry $Value=$ReadUninstall.GetValue("DisplayName") $outstring = "$computername,$value" out-file -filepath c:\path\filename.txt -encoding ascii -append -inputobject $outstring
  9. crobin1

    Basic script not running

    Several methods I've run across won't automatically evaluate expressions such as what you have in your Create ("cn=" + $UserName). If you're working with strings you can see if the PowerShell automatic string expansion will get it, or create the full string before you call the method. See if...
  10. crobin1

    CMD script to search/replace & in file

    This script is bare-bones but will do it param( $infile = $(throw "Please specify an input filename"), $outfile ) if ($outfile -eq $null) { $outfile = $infile } $content = Get-Content $infile $content = $content -replace '&', '&' $content | Set-Content $outfile...
  11. crobin1

    Powershell Newbie

    Here's a sample script that should do what you want: $files = get-childitem \\server1\share1\*.txt foreach ($file in $files) { $basename = $file.BaseName if (-not(test-path -path \\server2\share2\$basename)) { mkdir \\server2\share2\$basename } move-item $file...
  12. crobin1

    Mailbox Size Script

    Does the account used to run the scheduled task have at least Modify permission to the C:\Scripts folder? From your description it sounds like it only has permission to create files and not also delete, which would be required to overwrite the existing file.
  13. crobin1

    Path name size

    I'm sure there's a better way to do it, but see where this leads you gci *.txt | foreach {$n = $_.FullName; if ($n.Length -gt 20) {write-host "$n $($n.Length)"}}
  14. crobin1

    Print variable

    It's an evaluation issue. I don't have the full answer, but try this: Write-Host "\\appsrv1\$($item.Folder)\$($item.File)"
  15. crobin1

    Running from VBScript logon script Permissions

    From your description, it doesn't sound like an Execution Policy issue. That only controls whether scripts can run or not. Execution Policy does not affect running commands directly, such as your embedded command. It seems more like a permissions issue with non-Administrator accounts. Maybe...
  16. crobin1

    Print variable

    Can you provide a sample of the XML file?
  17. crobin1

    NEED HELP WITH powershell

    Shouldn't this line: $Bios = gwmi -class Win32_BIOS -Comp $_ be this? $Bios = gwmi -class Win32_BIOS -Comp $strComputer
  18. crobin1

    Get mailbox itemcount for items with specific received date

    Right off hand I don't see that you can dig that deeply. The cmdlet Get-MailboxFolderStatistics will get you folder names and the counts within the folders: Get-MailboxFolderStatistics -identity mailboxalias | Select Identity, ItemsInFolder But it doesn't appear to let you step through the...
  19. crobin1

    Powershell script

    I think the double-quotes are part of the output from Export-CSV, probably to avoid issues with commas within fields. Probably your better bet is going to be to store the information in an array, and then output the array at the end of the script. You can see thread1619-1637606 for one example...
  20. crobin1

    Powershell script

    The Export-CSV cmdlet has a -Delimiter parameter which allows you to specify delimiters other than the comma. You should be able to do this in your second script: $files | select $db.name, Name, Filename, Size | Export-CSV -delimiter "|" -path "C:\DBFiles.txt" -notypeinformation

Part and Inventory Search

Back
Top