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...
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.
...you'll find it either empty or actually null since nothing gets assigned to it. Try splitting the line like this and see what happens
$configFiles = get-childitem $Dest *.config -recurse -verbose -force
$configFiles | out-file -width "500" -append $logrename
foreach ($file in $configFiles)
...
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...
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)...
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?
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
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...
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...
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.
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)"}}
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...
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...
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...
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.