Porting PowerShell Script from 2008 Server to 2012 Server

Hello,

We have a Powershell script that was written by a former employee. The script is attached.
The script runs fine on the 2008 server, but we cannot get it to run on the 2012 server. The script gathers iislogs from all our webservers, parses them, deletes, and inserts the data into a mssql database.
We are using Powershell_ise (x86) to run the script as administrator.
When starting the script, the starting script email is sent out, then the script just hangs. Nothing is written to the log file and nothing is written to C:\temp
New server has full access to \\prodfiles4\logs\windowsiislogs\mechanism\

The power shell output window shows this:

\\prodfiles4\logs\windowsiislogs\syslog\syslog.log 03-24-15  09:52:40       [000]        [INIT]        s                  [0310]       [02409676]        [001]       Documentation located at \\prodfiles4
\logs\windowsiislogs\mechanism\
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 

\\prodfiles4\logs\windowsiislogs\syslog\syslog.log 03-24-15  09:52:41       [000]        [INIT]        s                  [0310]       [02409676]        [001]       Cleaning up from last run, this can t
ake up to 500 seconds to complete  (this never completes)


When running on Server 2008 this same error appears, but the script runs fine, but we do get this error so I don't think this is necessarily bad.

Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest

The original author said he had to do a bunch of stuff to the 2008 server to make this script run, but does not remember exactly what.

Does anyone have any thoughts on getting this to run on a 2012 server?

Thank you,
logcollection-multithread-v10a.txt
LVL 1
xpediaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

footechCommented:
Your comparison
If ($SizeMb -ge $MaxLogSizeInMB)
isn't going to work the way you want because it's comparing a string to a number (int32).  Change where you define $SizeMb to
$SizeMb=[math]::Round(((Get-ChildItem $SysLogfile| Measure-Object -property length -sum).sum / 1MB),2)

Open in new window


The error message should reference the position in the script where the error occurred.  Can you post the full error and/or a screenshot of the console?  That would help to narrow things down.
xpediaAuthor Commented:
Thanks Footech,

Made the change as you suggested, but still no joy. Here is the output from server 2012

PS C:\Windows\system32> \\cco\dfs\logs\windowsiislogs\mechanism\logcollection-multithread_v10b.ps1
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:56:24       [000]        [INIT]        s                  [0310]       [02409676]        [001]       
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:56:24       [000]        [INIT]        s                  [0310]       [02409676]        [001]       ooooo                                
    .oooooo.             oooo  oooo                          .    o8o                                          
.o    .oooo.  
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:56:24       [000]        [INIT]        s                  [0310]       [02409676]        [001]       `888"                                
   d8P"  `Y8b            `888  `888                        .o8    `""                                         o8
88   d8P"`Y8b  
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:56:24       [000]        [INIT]        s                  [0310]       [02409676]        [001]        888          .ooooo.   .oooooooo    
  888           .ooooo.   888   888   .ooooo.   .ooooo.  .o888oo oooo   .ooooo.  ooo. .oo.        oooo    ooo  8
88  888    888
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:56:24       [000]        [INIT]        s                  [0310]       [02409676]        [001]        888         d88" `88b 888" `88b    
  888          d88" `88b  888   888  d88" `88b d88" `"Y8   888   `888  d88" `88b `888P"Y88b        `88.  .8"   8
88  888    888
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:56:24       [000]        [INIT]        s                  [0310]       [02409676]        [001]        888         888   888 888   888    
  888          888   888  888   888  888ooo888 888         888    888  888   888  888   888         `88..8"    8
88  888    888
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:56:24       [000]        [INIT]        s                  [0310]       [02409676]        [001]        888       o 888   888 `88bod8P"    
  `88b    ooo  888   888  888   888  888    .o 888   .o8   888 .  888  888   888  888   888          `888"     8
88  `88b  d88"
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:56:24       [000]        [INIT]        s                  [0310]       [02409676]        [001]       o888ooooood8 `Y8bod8P" `8oooooo.    
   `Y8bood8P"  `Y8bod8P" o888o o888o `Y8bod8P" `Y8bod8P"   "888" o888o `Y8bod8P" o888o o888o          `8"     o8
88o  `Y8bd8P"  
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:56:24       [000]        [INIT]        s                  [0310]       [02409676]        [001]                              d"     YD    
                                                                                                               
               
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:56:24       [000]        [INIT]        s                  [0310]       [02409676]        [001]                              "Y88888P"    
                                                                                                               
               
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:56:24       [000]        [INIT]        s                  [0310]       [02409676]        [001]       
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:56:24       [000]        [INIT]        s                  [0310]       [02409676]        [001]       Script init from locaton \\prodfiles4
.cco\logs\windowsiislogs\mechanism\
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:56:24       [000]        [INIT]        s                  [0310]       [02409676]        [001]       Documentation located at \\prodfiles4
.cco\logs\windowsiislogs\mechanism\
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:56:24       [000]        [INIT]        s                  [0310]       [02409676]        [001]       Cleaning up from last run, this can t
ake up to 500 seconds to complete

This is how the output should be and is running on server 2008:

PS C:\Users\admin.eddie> \\cco\dfs\logs\windowsiislogs\mechanism\logcollection-multithread_v10b.ps1
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:51       [000]        [INIT]        s                  [0167]       [05219462]        [000]       
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:51       [000]        [INIT]        s                  [0167]       [05219462]        [000]       ooooo                                    .oooooo.             oooo  oooo                          .    o8o                                           .o    .oo
oo.  
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:51       [000]        [INIT]        s                  [0167]       [05219462]        [000]       `888"                                   d8P"  `Y8b            `888  `888                        .o8    `""                                         o888   d8P"
`Y8b  
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        s                  [0167]       [05219462]        [000]        888          .ooooo.   .oooooooo      888           .ooooo.   888   888   .ooooo.   .ooooo.  .o888oo oooo   .ooooo.  ooo. .oo.        oooo    ooo  888  888  
  888
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        s                  [0167]       [05219462]        [000]        888         d88" `88b 888" `88b       888          d88" `88b  888   888  d88" `88b d88" `"Y8   888   `888  d88" `88b `888P"Y88b        `88.  .8"   888  888  
  888
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        s                  [0167]       [05219462]        [000]        888         888   888 888   888       888          888   888  888   888  888ooo888 888         888    888  888   888  888   888         `88..8"    888  888  
  888
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        s                  [0167]       [05219462]        [000]        888       o 888   888 `88bod8P"       `88b    ooo  888   888  888   888  888    .o 888   .o8   888 .  888  888   888  888   888          `888"     888  `88b
 d88"
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        s                  [0167]       [05219462]        [000]       o888ooooood8 `Y8bod8P" `8oooooo.        `Y8bood8P"  `Y8bod8P" o888o o888o `Y8bod8P" `Y8bod8P"   "888" o888o `Y8bod8P" o888o o888o          `8"     o888o  `Y8b
d8P"  
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        s                  [0167]       [05219462]        [000]                              d"     YD                                                                                                                              
     
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        s                  [0167]       [05219462]        [000]                              "Y88888P"                                                                                                                              
     
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        s                  [0167]       [05219462]        [000]       
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        s                  [0167]       [05219462]        [000]       Script init from locaton \\prodfiles4.cco\logs\windowsiislogs\mechanism\
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        s                  [0167]       [05219462]        [000]       Documentation located at \\prodfiles4.cco\logs\windowsiislogs\mechanism\
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        s                  [0167]       [05219462]        [000]       Cleaning up from last run, this can take up to 500 seconds to complete
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
Cannot find an overload for "op_Subtraction" and the argument count: "2".
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        s                  [0167]       [05219462]        [000]       All stale  threads cleaned
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]       Listing all settings
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]              ArchiveIISLogfile=\\prodfiles4.cco\logs\windowsiislogs\archive\03-25-02-58archivesIIS.rar
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]              ArchiveLocation=\\prodfiles4.cco\logs\windowsiislogs\archive\
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]              ArchiveSysLogfile=\\prodfiles4.cco\logs\windowsiislogs\archive\03-25-02-58archivesyslog.rar
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]              ArchiveSysLogTempfile=\\prodfiles4.cco\logs\windowsiislogs\archive\03-25-02-58archivesyslog.txt
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]              IISLogLocation=\\prodfiles4.cco\logs\windowsiislogs\temp
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]              MaximumAliasCount=4096
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]              MaximumDriveCount=4096
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]              MaximumErrorCount=256
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]              MaximumFunctionCount=4096
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]              MaximumHistoryCount=64
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]              MaximumVariableCount=4096
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]              MaxLogSizeInMB=20
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]              MaxThreads=25
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]              MyInvocation=System.Management.Automation.InvocationInfo
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]              ProcessedIISLogLocation=\\prodfiles4.cco\logs\windowsiislogs\processed\*.log
\\prodfiles4.cco\logs\windowsiislogs\syslog\syslog.log 03-25-15  02:58:52       [000]        [INIT]        0s                  [0167]       [05219462]        [000]              ServersFile=\\prodfiles4.cco\logs\ActiveServersAndPools\servers_testmulti.txt
No Keep flag for \\prodiispub6.cco\C$\WINDOWS\system32\LogFiles\W3SVC1289165116 and server prodiispub6.cco and sitename cobrands CORE cobrands WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE cobrands WARN
No Keep flag for \\prodiispub5.cco\C$\WINDOWS\system32\LogFiles\W3SVC1289165116 and server prodiispub5.cco and sitename cobrands CORE cobrands WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE cobrands WARN
No Keep flag for \\prodiispub6.cco\c$\WINDOWS\system32\LogFiles\W3SVC1099807143 and server prodiispub6.cco and sitename PRN CORE PRN WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE PRN WARN
No Keep flag for \\prodiispub5.cco\c$\WINDOWS\system32\LogFiles\W3SVC1099807143 and server prodiispub5.cco and sitename PRN CORE PRN WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE PRN WARN
Cannot find path '\\prodiislegacy01.cco\c$\inetpub\logs\LogFiles\W3SVC1099807143' because it does not exist.
    + CategoryInfo          : ObjectNotFound: (\\prodiislegacy...W3SVC1099807143:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
 
No Keep flag for \\prodiislegacy01.cco\c$\inetpub\logs\LogFiles\W3SVC1099807143 and server prodiislegacy01.cco and sitename PRN CORE PRN WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE PRN WARN
No Keep flag for \\prodiispriv34.CCO\C$\inetpub\logs\LogFiles\W3SVC3 and server prodiispriv34.CCO and sitename internal.gateway CORE internal.gateway WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE internal.gateway WARN
deletion of log \\prodiispriv34.CCO\C$\inetpub\logs\LogFiles\W3SVC3\u_extend678843.log completed CORE WARN
deletion of log \\prodiispriv34.CCO\C$\inetpub\logs\LogFiles\W3SVC3\u_extend678842.log completed CORE WARN
Cannot find path '\\prodiislegacy02.cco\c$\inetpub\logs\LogFiles\W3SVC1289165116' because it does not exist.
    + CategoryInfo          : ObjectNotFound: (\\prodiislegacy...W3SVC1289165116:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
 
No Keep flag for \\prodiislegacy02.cco\c$\inetpub\logs\LogFiles\W3SVC1289165116 and server prodiislegacy02.cco and sitename cobrand CORE cobrand WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE cobrand WARN
No Keep flag for \\prodiispfpro01.cco\c$\inetpub\logs\LogFiles\W3SVC1 and server prodiispfpro01.cco and sitename pfpro CORE pfpro WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE pfpro WARN
Cannot find path '\\prodiislegacy03.cco\c$\inetpub\logs\LogFiles\W3SVC1289165116' because it does not exist.
    + CategoryInfo          : ObjectNotFound: (\\prodiislegacy...W3SVC1289165116:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
 
No Keep flag for \\prodiislegacy03.cco\c$\inetpub\logs\LogFiles\W3SVC1289165116 and server prodiislegacy03.cco and sitename cobrand CORE cobrand WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE cobrand WARN
Cannot find path '\\prodiislegacy03.cco\c$\inetpub\logs\LogFiles\W3SVC1289165116' because it does not exist.
    + CategoryInfo          : ObjectNotFound: (\\prodiislegacy...W3SVC1289165116:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
 
No Keep flag for \\prodiislegacy03.cco\c$\inetpub\logs\LogFiles\W3SVC1289165116 and server prodiislegacy03.cco and sitename cobrand CORE cobrand WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE cobrand WARN
Cannot find path '\\prodiislegacy03.cco\c$\inetpub\logs\LogFiles\W3SVC2063602439' because it does not exist.
    + CategoryInfo          : ObjectNotFound: (\\prodiislegacy...W3SVC2063602439:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
 
No Keep flag for \\prodiislegacy03.cco\c$\inetpub\logs\LogFiles\W3SVC2063602439 and server prodiislegacy03.cco and sitename privateeye CORE privateeye WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE privateeye WARN
No Keep flag for \\prodiispriv30.cco\c$\inetpub\logs\LogFiles\W3SVC1 and server prodiispriv30.cco and sitename transactions CORE transactions WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE transactions WARN
Cannot find path '\\prodiislegacy02.cco\c$\inetpub\logs\LogFiles\W3SVC1099807143' because it does not exist.
    + CategoryInfo          : ObjectNotFound: (\\prodiislegacy...W3SVC1099807143:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
 
No Keep flag for \\prodiislegacy02.cco\c$\inetpub\logs\LogFiles\W3SVC1099807143 and server prodiislegacy02.cco and sitename PRN CORE PRN WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE PRN WARN
Cannot find path '\\prodiislegacy01.cco\c$\inetpub\logs\LogFiles\W3SVC1289165116' because it does not exist.
    + CategoryInfo          : ObjectNotFound: (\\prodiislegacy...W3SVC1289165116:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
 
No Keep flag for \\prodiislegacy01.cco\c$\inetpub\logs\LogFiles\W3SVC1289165116 and server prodiislegacy01.cco and sitename cobrand CORE cobrand WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE cobrand WARN
Cannot find path '\\prodiislegacy03.cco\c$\inetpub\logs\LogFiles\W3SVC1099807143' because it does not exist.
    + CategoryInfo          : ObjectNotFound: (\\prodiislegacy...W3SVC1099807143:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
 
No Keep flag for \\prodiislegacy03.cco\c$\inetpub\logs\LogFiles\W3SVC1099807143 and server prodiislegacy03.cco and sitename PRN CORE PRN WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE PRN WARN
Cannot find path '\\prodiislegacy03.cco\c$\inetpub\logs\LogFiles\W3SVC1099807143' because it does not exist.
    + CategoryInfo          : ObjectNotFound: (\\prodiislegacy...W3SVC1099807143:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
 
No Keep flag for \\prodiislegacy03.cco\c$\inetpub\logs\LogFiles\W3SVC1099807143 and server prodiislegacy03.cco and sitename PRN CORE PRN WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE PRN WARN
No Keep flag for \\prodiispfpro03.cco\c$\inetpub\logs\LogFiles\W3SVC1 and server prodiispfpro03.cco and sitename pfpro CORE pfpro WARN
Starting deletion of logs given missing flag value though will leave 3 most recent logs in place CORE pfpro WARN
No Keep flag for \\prodiisdt02.cco\c$\inetpub\logs\LogFiles\W3SVC1 and server prodiisdt02.cco and sitename DT CORE DT WARN
footechCommented:
Just to be clear, I wasn't saying that would fix your error, just that it wouldn't work the way you want.  There are scenarios where it will give an unexpected result.

The op_subtraction error is probably coming from this line.
$CommandOuput = Invoke-Expression "$($WinZip ) a -dw $ArchiveSysLogfile $ArchiveSysLogTempfile" 2>&1
But it could also be one of these two.
$runtime =  "{0:0000.00}" -f [int] ('{0:N3}' -f ((Get-Date)-$ScriptStartDTM).totalseconds)

Write-Host $SysLogfile "$(get-date -f MM-dd-yy"  "hh:mm:ss)`t [$($threadID)] `t [$($loglevel)] `t $("{0:N0}" -f ((Get-Date)-$ScriptStartDTM).totalseconds)s`t $($sitename)`t [$TotalFilesProcessed] `t[$elementsprocessed] `t [$MaxThreads]`t $($logstring)"

Open in new window


This is the portion that's not working.
While ($(Get-Job -state running | Where-Object {$_.Name.Contains("logcollection")} ).count -ne $null){
                Get-Job -State Completed | Where-Object {$_.Name.Contains("logcollection")}  | Stop-job
                Get-Job -State Completed  | Where-Object {$_.Name.Contains("logcollection")} | Remove-Job
                Get-Job -State Stopped | Where-Object {$_.Name.Contains("logcollection")} | Remove-Job
                Start-Sleep 1
                $currentwait ++
                if ($currentwait -gt $threadTimeout) {
                    LogWrite "hit max wait time, ending all current threads now" "0" "INIT"
                    Get-Job  | Where-Object {$_.Name.Contains("logcollection")} | remove-job -f
                }
            }

Open in new window

Most likely because the condition isn't being met.  Try adding this at the start of the script.
Set-StrictMode -Version 2.0

Open in new window

It should help with identifying some errors.  But I think I finally spotted the problem.
Change this line
While ($(Get-Job -state running | Where-Object {$_.Name.Contains("logcollection")} ).count -ne $null){
to
While ($(Get-Job -state running | Where-Object {$_.Name.Contains("logcollection")} ).count -ne 0){

Open in new window


The way the "count" property is handled changed a bit after PowerShell 2.0.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
xpediaAuthor Commented:
Footech,

You are truly a genius!

Script is now working correctly on the new server.

Thank you,
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.