# Skype for Business System Status Script Help

**URL:** <https://forums.powershell.org/t/skype-for-business-system-status-script-help/17057>\
**Category:** PowerShell Help\
**Created:** [July 12, 2021, 4:29pm UTC](https://forums.powershell.org/t/skype-for-business-system-status-script-help/17057 "2021-07-12T16:29:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ckrafcky](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@ckrafcky](https://forums.powershell.org/u/ckrafcky)\
**Post date:** [July 12, 2021, 4:29pm UTC](https://forums.powershell.org/t/skype-for-business-system-status-script-help/17057/1 "2021-07-12T16:29:10Z")

</div>

Hello - I’m new to the forum, as well as Powershell. For the most part I’ve gotten through the script, but for some reason it now throws an error that I hadn’t seen before.

Errors:

```auto
Cannot convert value "Not collected" to type "System.Int32". Error: "Input string was not in a correct format."
At C:\Users\a-ckrafcky\Desktop\SystemStatus\SystemStatus.ps1:1712 char:7
+ $intErrors = [int]$_.Errors
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastFromStringToInteger

Cannot convert value "Not collected" to type "System.Int32". Error: "Input string was not in a correct format."
At C:\Users\a-ckrafcky\Desktop\SystemStatus\SystemStatus.ps1:1729 char:7
+ $intWarnings = [int]$_.Warnings
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastFromStringToInteger

Cannot convert value "Not collected" to type "System.Int32". Error: "Input string was not in a correct format."
At C:\Users\a-ckrafcky\Desktop\SystemStatus\SystemStatus.ps1:1712 char:7
+ $intErrors = [int]$_.Errors
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastFromStringToInteger

Cannot convert value "Not collected" to type "System.Int32". Error: "Input string was not in a correct format."
At C:\Users\a-ckrafcky\Desktop\SystemStatus\SystemStatus.ps1:1729 char:7
+ $intWarnings = [int]$_.Warnings
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastFromStringToInteger

Cannot convert value "Not collected" to type "System.Int32". Error: "Input string was not in a correct format."
At C:\Users\a-ckrafcky\Desktop\SystemStatus\SystemStatus.ps1:1712 char:7
+ $intErrors = [int]$_.Errors
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastFromStringToInteger

Cannot convert value "Not collected" to type "System.Int32". Error: "Input string was not in a correct format."
At C:\Users\a-ckrafcky\Desktop\SystemStatus\SystemStatus.ps1:1729 char:7
+ $intWarnings = [int]$_.Warnings
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastFromStringToInteger

```

If the whole code is required, what is the allowed format to get it into the post?

---

<div class="post-metadata">

**Author:** ![tonyd](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tonyd/32/1041_2.png) [@tonyd](https://forums.powershell.org/u/tonyd)\
**Post date:** [July 12, 2021, 4:39pm UTC](https://forums.powershell.org/t/skype-for-business-system-status-script-help/17057/2 "2021-07-12T16:39:37Z")

</div>

Ouch … 1700+ lines of code? How about starting with line number 1712 and 1729, the ones generating the errors.

---

<div class="post-metadata">

**Author:** ![ckrafcky](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@ckrafcky](https://forums.powershell.org/u/ckrafcky)\
**Post date:** [July 12, 2021, 4:41pm UTC](https://forums.powershell.org/t/skype-for-business-system-status-script-help/17057/3 "2021-07-12T16:41:18Z")

</div>

````auto
#Check out state of errors - 7
		#--------------------------------
		If ($_.Errors -ne "n/a" -and ($_.Errors -match "[0-9]*")){
		    $intErrors = [int]$_.Errors
		} Else {
		    $intErrors = 0
		}
		if ($intErrors -gt 10) {
			$strColour = "#ff0000"
		} Else {
			$strColour = "#66CD00"
		}
		$strHTMLRowNew = $strHTMLRowNew -Replace "\<ERRORS\>",$_.Errors
		$strHTMLRowNew = $strHTMLRowNew -Replace "\<COLOUR7\>",$strColour
		$strDescription = $_.Description + ";$intErrors"
		#--------------------------------
        
        #Warnings - 8
		#--------------------------------
		If ($_.Warnings -ne "n/a" -and ($_.Warnings -match "[0-9]*")){
		    $intWarnings = [int]$_.Warnings
		} Else {
		    $intWarnings = 0
		}
		if ($intWarnings -gt 50) {
			$strColour = "#ff0000"
		} Else {
			$strColour = "#66CD00"
		}
		$strHTMLRowNew = $strHTMLRowNew -Replace "\<WARNINGS\>",$_.Warnings
		$strHTMLRowNew = $strHTMLRowNew -Replace "\<COLOUR8\>",$strColour
		$strDescription = $_.Description + ";WARN-$intWarnings;"
        #--------------------------------
        
        #$strColour = "#ffd700"
		#$strHTMLRowNew = $strHTMLRowNew -Replace "\<GATEWAY\>",$_.Gateway
		```

````

type or paste code here

```auto

```

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [July 12, 2021, 4:41pm UTC](https://forums.powershell.org/t/skype-for-business-system-status-script-help/17057/4 "2021-07-12T16:41:39Z")

</div>

ckrafcky10,  
Welcome back to the forum. 👋🏽

> [@ckrafcky](#):
>
> If the whole code is required,

If you expect specific help you should share the specific part of your code producing this errors. 😉

In genereal: it seems like you provide a string `"Not collected"` where your script expects an integer.

> [@ckrafcky](#):
>
> what is the allowed format to get it into the post?

Just format it like you formatted the eror message you posted. 😉

---

<div class="post-metadata">

**Author:** ![ckrafcky](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@ckrafcky](https://forums.powershell.org/u/ckrafcky)\
**Post date:** [July 12, 2021, 4:44pm UTC](https://forums.powershell.org/t/skype-for-business-system-status-script-help/17057/5 "2021-07-12T16:44:58Z")

</div>

Thanks for the quick replies. I’ve provided the portion of code as a reply to tonyd. Bear in mind that I didn’t write this code, I am just trying to decipher it and get it to do what I’d like.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [July 12, 2021, 4:47pm UTC](https://forums.powershell.org/t/skype-for-business-system-status-script-help/17057/6 "2021-07-12T16:47:18Z")

</div>

> [@ckrafcky](#):
>
> Bear in mind that I didn’t write this code

So you may ask the author of the code to help you debugging it!? 🤨

Obviously your variable `$_.Errors` containes more than just numbers or just numbers greater than an [INT] allowes.

---

<div class="post-metadata">

**Author:** ![tonyd](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tonyd/32/1041_2.png) [@tonyd](https://forums.powershell.org/u/tonyd)\
**Post date:** [July 12, 2021, 5:13pm UTC](https://forums.powershell.org/t/skype-for-business-system-status-script-help/17057/7 "2021-07-12T17:13:02Z")

</div>

The code is forcing a type cast of Integer to [Int]$\_.Errors. It looks like there is a match for 0-9, but also contains string values as well. The first thing I would try is removing the type cast and see what happens.

```auto
$intErrors = $_.Errors

```

```auto
$intWarning = $_.Errors

```

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:23pm UTC](https://forums.powershell.org/t/skype-for-business-system-status-script-help/17057/8 "2024-05-16T20:23:50Z")

</div>

Closed on May 16, 2024, 8:23pm UTC


