Script Runs Fine in Debug, Errors in Normal Run
Posted: Tue Jun 09, 2020 8:16 am
To help you better we need some information from you.
*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***
Product: PowerShell Studio 2020 (64 Bit)
Build: v5.7.178
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.18362.0
*** Please add details and screenshots as needed below. ***
DO NOT POST LICENSES, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
I use the below script ( a little more comes above it, but this is where it is breaking) to update our Employee ID's in the AD Extension employeeID field.
Something weird is happening, I am not sure if it is with the way it counts the INTs or what, but when I run it with just the play button (or through a compiled EXE) it errors out and says check the spelling of "*S*", but when I run it in DEBUG mode, no errors whatsoever.
This makes it difficult to debug when debug mode works fine but production mode does not. Any ideas?
*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***
Product: PowerShell Studio 2020 (64 Bit)
Build: v5.7.178
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.18362.0
*** Please add details and screenshots as needed below. ***
DO NOT POST LICENSES, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
I use the below script ( a little more comes above it, but this is where it is breaking) to update our Employee ID's in the AD Extension employeeID field.
Something weird is happening, I am not sure if it is with the way it counts the INTs or what, but when I run it with just the play button (or through a compiled EXE) it errors out and says check the spelling of "*S*", but when I run it in DEBUG mode, no errors whatsoever.
This makes it difficult to debug when debug mode works fine but production mode does not. Any ideas?
- function Update-EIDs
- {
- $logfile = "Log File for Employee EID Updates in AD`r`n`r`n" #Preps the logfile
- $todaysDate = get-date #Gets the date for the logfile
- $logDate = $todaysDate.ToShortDateString() #Formats the date for the logfile
- $LogfilenameDate = get-date -format MMddyy #Gets the date for the filename
- $logfileName = "EID Update Log for " + $LogfilenameDate #Sets the filename for the log
- $logfilePath = "\\server\homedrives\myuser\" + $logfileName + ".txt" #Sets the full path for the log file
- $global:logDate = (Get-Date -Format "MMM dd yyyy")
- try
- {
- $i = 0
- [int]$total = ($eids | Measure-Object).Count
- while ($i -lt $total)
- {
- $wildcard = "*" + $eidusers[$i] + "*"
- $currentuser = Get-ADUser -Filter { name -like $wildcard -and name -notlike "*(Elevated)*" } | select -ExpandProperty samaccountname
- Set-ADUser $currentuser -EmployeeID $eids[$i]
- $i++
- }
- [System.Windows.Forms.MessageBox]::Show('Success')
- }
- catch
- {
- if ($i -eq ($lines | Measure-Object).Count) { Return }
- else
- {
- $errorMessage = "Check spelling of" + $wildcard
- [System.Windows.Forms.MessageBox]::Show($errorMessage) #Shows an exception error message if there is one. This will happen if the list you received has a misspelled name or if it couldn't find the user (if they have spaces in their name where they shouldn't, etc...)
- }
- }