<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lenovo warranty with Powershell Archives - the Sysadmin Channel</title>
	<atom:link href="https://thesysadminchannel.com/tag/lenovo-warranty-with-powershell/feed/" rel="self" type="application/rss+xml" />
	<link>https://thesysadminchannel.com/tag/lenovo-warranty-with-powershell/</link>
	<description>Documenting My Life as a System Administrator</description>
	<lastBuildDate>Sat, 13 Oct 2018 02:28:25 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>
<site xmlns="com-wordpress:feed-additions:1">144174110</site>	<item>
		<title>How to Get Lenovo Warranty Expiration Status With Powershell &#124; Lenovo Warranty Lookup</title>
		<link>https://thesysadminchannel.com/get-lenovo-warranty-expiration-status-with-powershell/</link>
					<comments>https://thesysadminchannel.com/get-lenovo-warranty-expiration-status-with-powershell/#respond</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Sun, 22 Apr 2018 04:54:58 +0000</pubDate>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[get lenovo warranty script]]></category>
		<category><![CDATA[Lenovo warranty check]]></category>
		<category><![CDATA[lenovo warranty lookup]]></category>
		<category><![CDATA[Lenovo warranty with Powershell]]></category>
		<category><![CDATA[powershell get lenovo warranty]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=377</guid>

					<description><![CDATA[<p>If you&#8217;re using Lenovo laptops in your environment you most likely have checked to see if your machine is still under warranty.  The Lenovo Warranty Status page works great, the only problem is, is that it doesn&#8217;t scale to well.  For&#8230; <a href="https://thesysadminchannel.com/get-lenovo-warranty-expiration-status-with-powershell/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/get-lenovo-warranty-expiration-status-with-powershell/">How to Get Lenovo Warranty Expiration Status With Powershell | Lenovo Warranty Lookup</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If you&#8217;re using Lenovo laptops in your environment you most likely have checked to see if your machine is still under warranty.  The <a href="https://pcsupport.lenovo.com/us/en/warrantylookup?linkTrack=Mast:SubNav:Support:Warranty%20and%20Repair:Warranty|Check%20Warranty%20Status" target="_blank" rel="noopener">Lenovo Warranty Status page</a> works great, the only problem is, is that it doesn&#8217;t scale to well.  For example,  what if you needed to check the warranty status of 10 Lenovo laptops, what about 20,  or even 1000?  Yeah, I don&#8217;t see myself typing in the serial number for 1000 Lenovo machines into their status checker.  This could take forever and a day to complete and we have way better things to be doing with out time.  Luckily we have <strong>Powershell to Get Lenovo Warranty Expiration Status</strong> in all its glory. Here is the easy peazy way to get a Lenovo warranty lookup.</p>
<p>Inspired by Reddit user <a href="https://www.reddit.com/user/dungeongoon" target="_blank" rel="noopener">dungeongoon</a> in this <a href="https://www.reddit.com/r/PowerShell/comments/8drobr/new_to_powershell_look_for_feedback_on_first/" target="_blank" rel="noopener">Post</a> I decided to modify the work that he did and put a little twist of my own so I can get the output that I thought was necessary for me. For one, I kept on getting errors when I tried using Get-CimInstance since my environment didn&#8217;t have WinRM enabled. Thus, I had to continue to use the Get-WMIObject for consistent results.  Second, I wanted to be pass multiple computers in the command line or pass an array of objects so I modified it as such.</p>
<h1>Requirements</h1>
<p>No Powershell requirements are needed.</p>
<h1>Parameters</h1>
<h3>    -ComputerName</h3>
<p>Description: Specify one or multiple computer names to pass through the function.</p>
<h3>    -IncudeBatteryExpiration</h3>
<p>Description: If specified, it will show if the Battery is still under warranty.  The ID type specified is &#8220;1EZ*&#8221;</p>
<h1>Examples</h1>
<p><strong>Example 1: Display the warranty information for the current Lenovo computer</strong></p>
<pre class="brush: powershell; title: ; notranslate">

PS C:\&gt; Get-LenovoWarranty


ComputerName  : PC1
Type          : BASE
ID            : 3EZ
StartDate     : 2015-01-08
EndDate       : 2018-02-21
DaysRemaining : 0
Status        : Expired

</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2018/04/Get-LenovoWarranty.png" target="_blank"><img fetchpriority="high" decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2018/04/Get-LenovoWarranty.png" alt="Get-LenovoWarranty" width="829" height="399" class="aligncenter size-full wp-image-391" srcset="https://thesysadminchannel.com/wp-content/uploads/2018/04/Get-LenovoWarranty.png 829w, https://thesysadminchannel.com/wp-content/uploads/2018/04/Get-LenovoWarranty-768x370.png 768w" sizes="(max-width: 829px) 100vw, 829px" /></a></p>
<p>&nbsp;</p>
<p><strong>Example 2: Specify a computer name or multiple computer names separated by a comma.</strong></p>
<pre class="brush: powershell; title: ; notranslate">

PS C:\&gt; Get-LenovoWarranty -ComputerName PC1, PC2


ComputerName  : PC1
Type          : BASE
ID            : 3EZ
StartDate     : 2015-01-08
EndDate       : 2018-02-21
DaysRemaining : 0
Status        : Expired

ComputerName  : PC2
Type          : BASE
ID            : 3EZ
StartDate     : 2016-03-25
EndDate       : 2019-05-08
DaysRemaining : 381
Status        : Active
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2018/04/Get-LenovoWarranty-ComputerName.png" target="_blank"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2018/04/Get-LenovoWarranty-ComputerName.png" alt="Get-LenovoWarranty-ComputerName" width="829" height="459" class="aligncenter size-full wp-image-396" srcset="https://thesysadminchannel.com/wp-content/uploads/2018/04/Get-LenovoWarranty-ComputerName.png 829w, https://thesysadminchannel.com/wp-content/uploads/2018/04/Get-LenovoWarranty-ComputerName-768x425.png 768w" sizes="(max-width: 829px) 100vw, 829px" /></a></p>
<p>&nbsp;</p>
<p><strong>Example 3: Use the -IncudeBatteryExpiration parameter to determine if the battery warranty has expired.</strong></p>
<pre class="brush: powershell; title: ; notranslate">

PS C:\&gt; Get-LenovoWarranty -IncudeBatteryExpiration


ComputerName  : PC1
Type          : BASE
ID            : 3EZ
StartDate     : 2015-01-08
EndDate       : 2018-02-21
DaysRemaining : 0
Status        : Expired

ComputerName  : PC1
Type          : BASE
ID            : 1EZBAT
StartDate     : 2015-01-08
EndDate       : 2016-02-21
DaysRemaining : 0
Status        : Expired

</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2018/04/Get-LenovoWarranty-IncludeBatteryExpiration.png" target="_blank"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2018/04/Get-LenovoWarranty-IncludeBatteryExpiration.png" alt="Get-LenovoWarranty-IncludeBatteryExpiration" width="829" height="459" class="aligncenter size-full wp-image-398" srcset="https://thesysadminchannel.com/wp-content/uploads/2018/04/Get-LenovoWarranty-IncludeBatteryExpiration.png 829w, https://thesysadminchannel.com/wp-content/uploads/2018/04/Get-LenovoWarranty-IncludeBatteryExpiration-768x425.png 768w" sizes="(max-width: 829px) 100vw, 829px" /></a><br />
The box in red highlights the battery expiration information.<br />
&nbsp;</p>
<p>Now let&#8217;s get to the script to get the Lenovo Warranty Information.</p>
<h1>Script to Get Lenovo Warranty Expiration Status</h1>
<pre class="brush: powershell; title: ; notranslate">

Function Get-LenovoWarranty {

&lt;#
.SYNOPSIS
    This will check the warranty status of a Lenovo laptop
    For updated help and examples refer to -Online version.
 
.DESCRIPTION
    This will check the warranty status of a Lenovo laptop
    For updated help and examples refer to -Online version.
 
.NOTES  
    Name: Get-LenovoWarranty
    Author: The Sysadmin Channel
    Version: 1.0
    DateCreated: 2018-Apr-21
    DateUpdated: 2018-Apr-21
 
.LINK
    https://thesysadminchannel.com/get-lenovo-warranty-expiration-status-with-powershell/ -
    For updated help and examples refer to -Online version.
 
#&gt;

    [CmdletBinding()]

    Param (
        [Parameter(
            ValueFromPipeline=$true,
            ValueFromPipelineByPropertyName=$true,
            Position=0)]
        
        [String[]]  $ComputerName = $env:COMPUTERNAME,

        [Parameter()]
        [switch]    $IncudeBatteryExpiration
        ) 

    BEGIN {
        $Object = @()
        $Today = Get-Date -Format 'yyyy-MM-dd'
    }

    PROCESS {
        Foreach ($Computer in $ComputerName) {
            Try {
                $Bios = Get-WmiObject Win32_Bios -ComputerName $Computer -ErrorAction Stop
                $SerialNumber = $Bios.SerialNumber
                $Manufacturer = $Bios.Manufacturer

                    If ($Manufacturer -eq &quot;LENOVO&quot;) {
                            $ApiObject = Invoke-RestMethod -Uri &quot;http://supportapi.lenovo.com/V2.5/Warranty?Serial=$SerialNumber&quot;
                        } else {
                            Write-Error &quot;BIOS manufacturer is not Lenovo; unable to proceed.&quot; -ErrorAction Stop
                    }

                    If ($IncudeBatteryExpiration) {
                            $Notebook = $ApiObject.Warranty | Where-Object {($_.ID -like &quot;1EZ*&quot;) -or ($_.ID -eq &quot;36Y&quot;) -or ($_.ID -eq &quot;3EZ&quot;)}
                        } else {
                            $Notebook = $ApiObject.Warranty | Where-Object {($_.ID -eq &quot;36Y&quot;) -or ($_.ID -eq &quot;3EZ&quot;)}    
                    }
                
                    foreach ($ID in $Notebook) {

                        $EndDate   = $ID.End.Split('T')[0]
                        $StartDate = $ID.Start.Split('T')[0]

                        if ($EndDate -gt $Today) {
                                $DaysRemaining = New-TimeSpan -Start $Today -End $EndDate | select -ExpandProperty Days
                                $DaysRemaining = $DaysRemaining - 1

                                $Properties = @{
                                                ComputerName  = $Computer
                                                Type          = $ID.Type
                                                ID            = $ID.ID
                                                StartDate     = $StartDate
                                                EndDate       = $EndDate
                                                DaysRemaining = $DaysRemaining
                                                Status        = 'Active'
                                                }

                            } else {
                                $Properties = @{
                                                ComputerName  = $Computer
                                                Type          = $ID.Type
                                                ID            = $ID.ID
                                                StartDate     = $StartDate
                                                EndDate       = $EndDate
                                                DaysRemaining = 0
                                                Status        = 'Expired'
                                                }

                        }
                    
                        $Object += New-Object -TypeName PSObject -Property $Properties | Select ComputerName, Type, ID, StartDate, EndDate, DaysRemaining, Status
                    }
                }

            catch {
                $ErrorMessage = $Computer + &quot; Error: &quot; + $_.Exception.Message

            } finally {

                Write-Output $Object
                $Object = $null

                    if ($ErrorMessage) {
                        #Write-Output $ErrorMessage
                        $ErrorMessage = $null
                    }
            }
        }

    }

    END {}

}

</pre>
<h1>How to run the script</h1>
<p>In order to the run the script there are a couple of things you need to do.  First and foremost, <a href="https://thesysadminchannel.com/set-execution-policy-in-powershell/" target="_blank" rel="noopener">set your execution policy</a> to RemoteSigned.  This is a standard with running <em>any</em> powershell script.</p>
<p>Next you need to dot source the script since it is a function.  To dot source the script do the following:</p>
<ul>
<li>Copy the script above and save it any location. In this example I&#8217;ll save it to my C:\_Scripts folder.</li>
<li>Within the Powershell Window running as Administrator type: <strong>. .\_Scripts\Get-LenovoWarranty.ps1 </strong>&#8211; Note the two dots before the backslash.</li>
</ul>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2018/04/Get-LenovoWarranty-Dot-Source.png" target="_blank"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2018/04/Get-LenovoWarranty-Dot-Source.png" alt="Get-LenovoWarranty Dot Source" width="841" height="459" class="aligncenter size-full wp-image-411" srcset="https://thesysadminchannel.com/wp-content/uploads/2018/04/Get-LenovoWarranty-Dot-Source.png 841w, https://thesysadminchannel.com/wp-content/uploads/2018/04/Get-LenovoWarranty-Dot-Source-768x419.png 768w" sizes="(max-width: 841px) 100vw, 841px" /></a></p>
<p>Hopefully this script has enabled you to find the Lenovo warranty information much faster.  As always, if you find any bugs within the script don&#8217;t hesitate to post it in the comments.</p>
<p>The post <a href="https://thesysadminchannel.com/get-lenovo-warranty-expiration-status-with-powershell/">How to Get Lenovo Warranty Expiration Status With Powershell | Lenovo Warranty Lookup</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/get-lenovo-warranty-expiration-status-with-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">377</post-id>	</item>
	</channel>
</rss>
