Jump to content

DarrenDK

Members
  • Content Count

    10
  • Joined

  • Last visited

  • Days Won

    3

DarrenDK last won the day on August 21

DarrenDK had the most liked content!

Community Reputation

10 Good

My Information

  • Agent Count
    1500+

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. DarrenDK

    Computer Warranty Updater (HP/Dell/Lenovo)

    OK, so chances are the HP API is not working as expected. The way to debug this is to first save the file in ISE, then it will let you set breakpoints (F9). You can put a breakpoint on the offending line number (248) and inspect the variables by hovering over them to see what they contain. What you'll likely find is that I'm not checking to make sure the results from the HP API are not null before attempting to insert them into database.
  2. DarrenDK

    Computer Warranty Updater (HP/Dell/Lenovo)

    Michael, You don't have to have Manage for this to work. The script will update the warrantyend and assetdate fields in the computers table of the Automate database. The problem is that the WarrantyEnd field doesn't appear to be exposed in the UI of Automate. However, I believe there are reports you can run that will expose this data. Or you can just make your own that use those fields.
  3. DarrenDK

    Computer Warranty Updater (HP/Dell/Lenovo)

    The Powershell that does the magic is inside of the LT script called "Update-Missing Warranties" which is under Immense Networks Scripts folder. You will find the API keys towards to bottom of that script. I'm not sure if it is 100% necessary to get your own key. I'm pretty sure Warranty Master is just using one key for all their clients. I think that's sort of the concept behind giving them to developers. Y'all can just use my keys until they shut us down lol.
  4. DarrenDK

    Computer Warranty Updater (HP/Dell/Lenovo)

    If you are getting this credential prompt, upgrade Powershell to version 5, or at least 4 but you might as well use 5. This is a known bug in Powershell 3.0 that ships with Server 2008 R2.
  5. DarrenDK

    Computer Warranty Updater (HP/Dell/Lenovo)

    My logging here could be better. I may update the script to include more verbose output. The HP API is the one that has the most anal rate limits. Basically you submit all the serial numbers you want to it as a batch job, then it tells you about how long the job will take, and you're not supposed to poll the API again until that time has elapsed, otherwise it will rate limit you and the job gets cancelled. I don't think this will be a problem but if it turns out to be I'll post instructions on how to get these keys. OK so the funny part about this is that I also can't find where it puts the warranty end date in the interface! This is why I decided to include the bit about syncing it to Manage. You can then use existing expiration workflow rules to trigger tickets opening or whatever you want. I have custom reports that pull these fields for QBRs. If you open a computer and click Show Details on the top, you can find Asset Date which is going to be the purchase date. I looked at this from the perspective of the database and placed the data in the fields that seemed to make the most sense.
  6. Ensure PowerShell version 4.0 or higher is installed on the LabTech Server itself (Needed for Invoke-RestMethod to not prompt for credentials) Extract LabTechWarrantyUpdaterModules.zip to C:\Program Files\WindowsPowershell\Modules Import Update-MissingWarranties.xml script into Automate, ignore warnings about version mismatch 11 - Tools->Import XML Expansion 12 - System->General->Import->XML Expansion Unrestrict the script execution policy on your LabTech Server Set-ExecutionPolicy Unrestricted -Confirm:$false -Force Open Immense Networks Scripts->Update-MissingWarranties, copy the value of the PowershellCode variable into Powershell ISE on the LabTech server and run it. There should be no errors about script execution or modules not found. You may get a rate limit error from the API, but that's relatively normal. Open your _System Automation->Onboarding->Initial System Configuration - Partner Script and insert a Script Run step that runs the Immense networks Scripts->Update-MissingWarranties script Open the Manage Plugin 11 - Click the Connectwise button on the top of the main LabTech Interface 12 - System->Manage Integration Set Manage Plugin to map the following fields (See screenshot below) PurchaseDate to Computer.Asset.TagDate WarrantyExpiration to Computer.Asset.WarrantyEndDate LabTechWarrantyUpdaterModules.zip Update-MissingWarranties.xml
  7. DarrenDK

    Help to Monitor a text file for an error

    It occurred to me that if it does disconnect once, even if you resolve it, the monitor will continue to restart the service every time it runs. Are you sure there isn't a better way to test this thing? Perhaps do a netstat -ano and see if the port is listening? Just a thought
  8. DarrenDK

    Help to Monitor a text file for an error

    Make an executable monitor with this as the executable path C:\Windows\system32\cmd.exe /c powershell.exe -ExecutionPolicy Bypass -Command "gci | sort LastWriteTime -Desc | select -First 1 | Get-Content | ?{$_ -like '*Cannot connect*'}" Tell it to use an alert template with Run Script on Warning or Error checked then select a LabTech script that will restart the service. Edit: You'll want to make sure you set the correct string match in the monitor also. Output contains 'appointuit' would probably work
  9. DarrenDK

    Importing Mobile Devices into Connectwise

    Yes, I am the author of the script. This can be deployed to your on premise Exchange servers and it will push the mobile devices into your Connectwise. The only hang up you may have is that if there are unrecognized email contacts (I.e. We see a phone associated with an email address that doesn't exist in Connectwise) then it won't create the new contact because it doesn't know what company to use. We already have Configuration items for the Email2Ticket plugin for CW that associated domains to Companies and this script will look for those configuration items for the Domain to Company association and then create the contacts if they don't exist. If you review the script you'll see what I'm doing and you can modify it accordingly.
  10. This script can be run daily against your Exchange Servers to update "Mobile Device" configurations. If you are using LabTech <11 you will need to run this with Shell as Admin I write the files as a text file and then execute it with Shell as Admin and then schedule it to run against the Exchange Server Search Group Daily. You will need an integrator login and password for this script which you can pass into the script as parameters. Param( [string]$ConnectwiseURL, [string]$ConnectwiseCompany, [string]$IntegratorLogin, [string]$IntegratorPassword ) function ConvertFrom-Canonical { param([string]$canonincal=(trow '$Canonical is required!')) $obj = $canonincal.Replace(',','\,').Split('/') [string]$DN = "CN=" + $obj[$obj.count - 1] for ($i = $obj.count - 2;$i -ge 1;$i--){$DN += ",OU=" + $obj[$i]} $obj[0].split(".") | ForEach-Object { $DN += ",DC=" + $_} return $dn } if((get-command -listimported).Name -notcontains "Get-Mailbox") { . ($env:exchangeinstallpath + 'bin\RemoteExchange.ps1') Connect-ExchangeServer -auto -ClientApplication:ManagementShell } if($devices -eq $null) { if((get-command -listimported).Name -notcontains "Get-MobileDevice") { $devices = Get-ActiveSyncDevice -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Get-ActiveSyncDeviceStatistics -ErrorAction SilentlyContinue -WarningAction SilentlyContinue } else { $devices = Get-MobileDevice -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Get-MobileDeviceStatistics -ErrorAction SilentlyContinue -WarningAction SilentlyContinue } } $ConfigurationAPI = New-WebServiceProxy -uri ("https://" + $ConnectwiseURL + "/v4_6_release/apis/2.0/ConfigurationAPI.asmx?wsdl") -Namespace ConnectWise -Class ConfigurationAPIClass $ReportingAPI = New-WebServiceProxy -uri ("https://" + $ConnectwiseURL + "/v4_6_release/apis/2.0/ReportingAPI.asmx?wsdl") -Namespace ConnectWise2 -Class ReportingAPIClass [ConnectWise.ApiCredentials] $ConfigurationAPICreds = New-Object ConnectWise.ApiCredentials [ConnectWise2.ApiCredentials] $ReportingAPICreds = New-Object ConnectWise2.ApiCredentials [ConnectWise.Configuration] $Configuration = New-Object ConnectWise.Configuration $ConfigurationAPICreds.CompanyId = $ConnectwiseCompany $ConfigurationAPICreds.IntegratorLoginId = $IntegratorLogin $ConfigurationAPICreds.IntegratorPassword = $IntegratorPassword $ReportingAPICreds.CompanyId = $ConnectwiseCompany $ReportingAPICreds.IntegratorLoginId = $IntegratorLogin $ReportingAPICreds.IntegratorPassword = $IntegratorPassword $AcceptedDomains = Get-AcceptedDomain $AcceptedDomains | %{ $AcceptedDomain = $_ if($AcceptedDomain.DomainName -like "*.local") { Write-Output ($AcceptedDomain.DomainName.ToString() + " ends in .local. Skipping...") } else { Write-Output ("Processing " + $AcceptedDomain.DomainName) $condition = ("Config_Type = 'Email2Ticket Domains' and Answer like '*@" + $AcceptedDomain.DomainName + "*'") $results = $ReportingAPI.RunReportQuery($ReportingAPICreds, "configuration", $condition, "", 1000, 0) $values = $results | %{$_.Value} $Company_RecID = ($values | ?{$_.Name -eq "Company_RecID"}).Value if($Company_RecID -eq $null) { Write-Output "Unable to find Email2Ticket Domain Configuration required to link this server to a Company in Connectwise" } else { $devices | %{ $device = $_ $mailboxidentity = ($device.Identity | Split-Path -Parent | Split-Path -Parent).Replace('\','/') if($mailboxidentity -ne $null) { $mailbox = Get-Mailbox -Identity $mailboxidentity -ErrorAction SilentlyContinue $EmailAddress = ($mailbox.EmailAddresses | ?{$_.IsPrimaryAddress}).SmtpAddress if($mailbox -ne $null -and $EmailAddress.EndsWith($AcceptedDomain.DomainName)) { Write-Output ("`t Processing " + $EmailAddress); #Determine if mailbox is a shared mailbox $IdentitiesWithPhones = $devices | %{($_.Identity | Split-Path -Parent | Split-Path -Parent).Replace('\','/')} | %{ ConvertFrom-Canonical $_ } $UsersWithAccessToMailbox = ($mailbox | Get-MailboxPermission | select User) #$SIDsWithAccessToMailbox = $UsersWithAccessToMailbox.SecurityIdentifier.Value $DNsWithAccessToMailbox = $UsersWithAccessToMailbox | %{ $user = $_ | Split-Path -Leaf $searchconditions = ("(samaccountname=" + $user + ")") $searcher = ([adsisearcher]$searchconditions) $searcherresult = $searcher.FindOne() $dn = $searcherresult.Properties.distinguishedname if($dn -ne $null) { $dn } } #$SIDsWithAccessToMailbox | ?{$_.Length -gt 20} | %{([adsi]("LDAP://" )).distinguishedName} $FilteredUsers = ($DNsWithAccessToMailbox | ?{$IdentitiesWithPhones -contains $_} | group).Name $IsSharedMailbox = $FilteredUsers.Count -gt 1 if($IsSharedMailbox -eq $false) { $condition = "Communication_Name = 'Email' and Contact_Communication_Desc = '$EmailAddress'" $results = $ReportingAPI.RunReportQuery($ReportingAPICreds, "ContactCommunication", $condition, "", 1000, 0) $values = $results | %{$_.Value} $Contact_RecID = ($values | ?{$_.Name -eq "Contact_RecID"}).Value $conditions = ("Serial_Number = '" + $device.DeviceId + "'") $ExistingDeviceResults = $ReportingAPI.RunReportQuery($ReportingAPICreds, "Configuration", $conditions,"",1000,0) $Configuration.CompanyId = $Company_RecID $Configuration.ConfigurationName = "" if($mailbox.Name -notlike "") { $Configuration.ConfigurationName += $mailbox.DisplayName } if(($device.DeviceFriendlyName -notlike "" -or $device.DeviceModel -notlike "") -and $mailbox.Name -notlike "" ) { $Configuration.ConfigurationName += "'s " } if($device.DeviceFriendlyName -notlike "") { $Configuration.ConfigurationName += $device.DeviceFriendlyName } elseif($device.DeviceModel -notlike "") { $Configuration.ConfigurationName += $device.DeviceModel } if($Contact_RecID.Count -gt 1) { Write-Output ($mailbox.PrimarySmtpAddress.ToString() + " matches multiple Connectwise Contacts") } Write-Output ("Contact_RecID: $Contact_RecID") $Configuration.ContactId = $Contact_RecID | select -First 1 $Configuration.ConfigurationTypeId = 97 #$Configuration.ConfigurationType = "Mobile Device" $Configuration.InstallationDate = $device.FirstSyncTime $Configuration.ModelNumber = $device.DeviceModel $Configuration.SerialNumber = $device.DeviceId $Configuration.OSInfo = $device.DeviceOS if($device.LastSuccessSync -ne $null) { $Configuration.WarrantyExpiration = $device.LastSuccessSync } if( $device.LastSuccessSync -gt (Get-Date).AddMonths(-1)) { #$Configuration.Status = "Inactive" $Configuration.StatusId = 2 } else { $Configuration.StatusId = 3 } if($ExistingDeviceResults.Count -eq 0) { try { $SubmittedConfiguration = $ConfigurationAPI.AddConfiguration($ConfigurationAPICreds, $Configuration) Write-Output ("Added Configuration for " + $SubmittedConfiguration.ConfigurationName + " under " + $AcceptedDomain) } catch { Write-Host $_ } } else { $values = $ExistingDeviceResults | %{$_.Value} $Configuration_RecID = ($values | ?{$_.Name -eq "Config_RecID"} | select -First 1).Value $Configuration.Id = $Configuration_RecID $SubmittedConfiguration = $ConfigurationAPI.UpdateConfiguration($ConfigurationAPICreds, $Configuration) Write-Output ("Updated Configuration for " + $SubmittedConfiguration.ConfigurationName + " under " + $AcceptedDomain) } } } } else { Write-Output ("Unable to determine mailbox Identity for " + $mailbox) } } } } }
×