title: Powershell command to check if the data type of variable is integer, if it has characters it should respond with a message "Enter Only number"
body: <pre><code>[int]$name = Read-Host Enter the KB number
  If ($name -is [int]) { 
      wusa /uninstall /kb:$name
      write-Host "This will uninstall windows update KB$name"
  } else {
      write-Host "Enter only the number"
  }
  </code></pre>
  
  <p>Here in this PowerShell scripts, whenever a characters is typed is returns an error instead of message "Enter only the number".</p>
  
  <pre><code>PS C:\Users\User\Desktop&gt; .\Test.ps1
  45454
  Enter the KB number: asfs
  Cannot convert value "asfs" to type "System.Int32". Error: "Input string was not in a correct format."
  At C:\Users\User\Desktop\Test.ps1:5 char:1
  + [int]$name = Read-Host Enter the KB number
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
      + FullyQualifiedErrorId : InvalidCastFromStringToInteger
  </code></pre>
  
  <p>This will uninstall windows update KB0</p>