Advertisement

09.18.2008 at 03:09PM PDT, ID: 23744188
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

Powershell error passing a vairable with a -

Asked by loftyworm in Scripting Languages, MSH/Monad PowerShell

I have a script that runs like this;

foreach($log in $logNames)
{
      $path = "\\{0}\c$\LogBackups\{0}$a{1}.evt" -f $Server,$log.LogFileName
      $result = ($log.BackupEventLog($path)).ReturnValue

This works great 98% of the time, but I have a log with the name Microsoft-Windows-Forwarding, and the script is failing out on this specific log.  I suspect it is the dashes in the log name that resides in the $log variable.  How do I pass this log name and the dashes?  (I can't change the Log name)

As I continue testing I find this;
PS C:\Logs> .\testLog_Retreiver.ps1
oit-sccm

                     FileSize LogfileName                   Name                                        NumberOfRecords
                     -------- -----------                   ----                                        ---------------
                        65536 Application                   C:\WINDOWS\system32\config...                            31

                        65536 DFS Replication               C:\WINDOWS\System32\config...                             0

                        65536 Internet Explorer             C:\WINDOWS\System32\Config...                             0

                        65536 Microsoft-Windows-Forwardi... C:\WINDOWS\system32\config...                             7
Move-Item : Cannot find path '\\SERVER\c$\LogBackups\SERVER2008-09-18-14-28-58Microsoft-Windows-Forwarding/Operational.evt' because it does not exist.
At C:\Logs\testLog_Retreiver.ps1:53 char:11
+     move-Item  <<<< $path -dest "C:\Logs\Backup\" -force

Perhaps it is not the dash that is causing problems, maybe it is the ...
Still having problemsStart Free Trial
 
Loading Advertisement...
 
[+][-]09.19.2008 at 04:43AM PDT, ID: 22520020

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Scripting Languages, MSH/Monad PowerShell
Sign Up Now!
Solution Provided By: Chris-Dent
Participating Experts: 1
Solution Grade: A
 
 
[+][-]09.19.2008 at 10:50AM PDT, ID: 22523641

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.19.2008 at 12:05PM PDT, ID: 22524308

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906