Password recovery and Factory Default on Cisco switch 2960 and 3560

Attach a terminal to the console port of the switch.
Use the following 
Unplug the power cable from the Switch.
Power the switch and bring it to the switch: prompt:
For 2900XL, 3500XL, 2940, 2950, 2960, 2970, 3550, 3560, and 3750 series switches, do this:
Hold down the mode button located on the left side of the front panel, while you reconnect the power cable to the switch.


2960, 2970
Release the Mode button when the SYST LED blinks amber and then turns solid green. When you release the Mode button, the SYST LED blinks green.

3560, 3750
Release the Mode button after approximately 15 seconds when the SYST LED turns solid green. When you release the Mode button, the SYST LED blinks green.
The system has been interrupted prior to initializing the flash file system to finish
loading the operating system software:
flash_init
load_helper
boot
switch:
Issue the flash_init command.
switch: flash_init Initializing Flash

Issue the load_helper command.
switch: load_helper switch:


Issue the dir flash: command.
Note: Make sure to type a colon ":" after the dir flash.
The switch file system is displayed:
switch: dir flash:


Type rename flash:config.text flash:config.old to rename the configuration file.
switch: rename flash:config.text flash:config.old


Issue the boot command to boot the system.
switch: boot
Enter "n" at the prompt to abort the initial configuration dialog.


At the switch prompt, type en to enter enable mode.
Switch>en Switch#

For password recovery

Type
 rename flash:config.old flash:config.text to rename the configuration file with its original name.
Switch#rename flash:config.old flash:config.text Destination filename [config.text]


Copy the configuration file into memory.
Switch#copy flash:config.text system:running-config Destination filename [running-config]?
The configuration file is now reloaded
Overwrite the current passwords that you do not know. Choose a strong password with at least one capital letter, one number, and one special character.
Note: Overwrite the passwords which are necessary. You need not overwrite all of the mentioned passwords.
Sw1# conf t !--- To overwrite existing secret password Sw1(config)#enable secret  !--- To overwrite existing enable password Sw1(config)#enable password  !--- To overwrite existing vty password Sw1(config)#line vty 0 15 Sw1(config-line)#password  Sw1(config-line)#login !--- To overwrite existing console password Sw1(config-line)#line con 0 Sw1(config-line)#password


·          
Write the running configuration to the configuration file with the write memory command.
Sw1#write memory Building configuration... [OK] Sw1#


For Factory reset:
don’t give below command for factory reset
Switch#copy flash:config.text system:running-config
do copy running config to flash,
Switch#copy running-config flash:
Destination filename [running-config]?
Building configuration...

Switch#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...



DHCP Server on Cisco 2960 Switches

ip dhcp excluded-address 172.17.0.1 172.17.0.50
ip dhcp pool 172.17.0.0/21
network 172.17.0.0 255.255.248.0
default-router 172.17.0.1 (yours)
dns-server 213.42.20.20 195.229.241.222 8.8.8.8
lease 4
ip dhcp snooping
ip dhcp-server 172.17.0.2
interface vlan 1
ip address 172.17.0.2

CONFIGURE PPPOE CONNECTION ON CISCO ROUTER 1841

Cisco 1841- erase everything on the router’s configuration and start from scratch.

router# configure terminal
router(config)# config-register 0x2102
router(config)# end
router#

router#write erase
router#reload

System configuration has been modified. Save? [yes/no]: n
Proceed with reload? [confirm]


Would you like to enter the initial configuration dialog? [yes/no]: n
Show the running config
Router#show run


Copy and Paste the following configuration into your router

no parser cache
no service pad
service timestamps debug uptime
service timestamps log uptime
service password-encryption
!
hostname cisco
!
boot-start-marker
boot-end-marker
!
!
mmi polling-interval 60
no mmi auto-configure
no mmi pvc
mmi snmp-timeout 180
no aaa new-model
ip subnet-zero
ip cef
!
!
ip dhcp excluded-address 172.17.0.1 172.17.0.50
!
ip dhcp pool 172.17.0.0/21
network 172.17.0.0 255.255.248.0
default-router 172.17.0.1
dns-server 213.42.20.20 195.229.241.222 8.8.8.8


Note:- 
  • If the DHCP Server is on different switch or firewall, remove the above-      given DHCP pool commands.
  • f0/1 IP address and access list, be same as that DHCP Server.
  • Don't forget to give this f0/1 IP Address as default router address on that DHCP Server.



!
!
no ip domain lookup
vpdn enable
!
vpdn-group 1
request-dialin
protocol pppoe
!
no ftp-server write-enable
!
interface FastEthernet0/0
description Physical_Internet_Interface
no ip address
no ip mroute-cache
duplex auto
speed auto
pppoe enable
pppoe-client dial-pool-number 1
no cdp enable
!
interface FastEthernet0/1
description Internal_LAN_Interface
ip address 172.17.0.1 255.255.248.0
ip nat inside
no ip mroute-cache
duplex auto
speed auto
no cdp enable
!
interface Dialer1
description Logical_Internet_Interface
ip address negotiated
ip mtu 1492
ip nat outside
encapsulation ppp
ip tcp adjust-mss 1452
no ip mroute-cache
dialer pool 1
dialer-group 1
no cdp enable
ppp authentication pap callin
ppp pap sent-username xxxxxxxx password xxxxxxxx
ppp ipcp dns request
ppp ipcp route default
ppp ipcp address accept
!
ip classless
!
!
no ip http server
no ip http secure-server
ip nat inside source list 10 interface Dialer1 overload
!
access-list 10 permit 172.17.0.0 0.0.7.255
dialer-list 1 protocol ip permit
no cdp run
!
!
control-plane
!
line con 0
exec-timeout 120 0
stopbits 1
line aux 0
line vty 0 4
exec-timeout 0 0
login local
length 0
!
scheduler max-task-time 5000
---------------------------------------------

Don't forget no shutdown command on interface f0/0 and f0/1

interface fastEthernet 0/0
no shut
interface fastEthernet 0/1
no shut
exit

Save the configuration after the test.

write memory



Windows PowerShell commands


        %                     Alias for ForEach-Object
        ?                     Alias for Where-Object
a
    Get-Acl                   Get permission settings for a file or registry key
    Set-Acl                   Set permissions
        Active Directory      Account, Computer, Group and User cmdlets
    Get-Alias           gal   Return alias names for Cmdlets
 Import-Alias          ipal   Import an alias list from a file
    New-Alias           nal   Create a new alias.
    Set-Alias           sal   Create or change an alias
 Compress-Archive             Create a new archive/zipped file [PS 5+]
   Expand-Archive             Extract files from an archive (zipped) file [PS 5+]
   Get-AuthenticodeSignature  Get the signature object associated with a file
   Set-AuthenticodeSignature  Place a signature in a .ps1 script or other file
b
       Backup-GPO             Backup group policy objects (GPOs)
       Begin                  Function BEGIN block
       BITS                   Background Intelligent Transfer Service cmdlets
       Break                  Exit a program loop
c
     Catch                    Handle a terminating error within a scriptblock
   Set-Location  cd/chdir/sl  Set the current working location
   Get-ChildItem   dir/ls/gci Get child items (contents of a folder or registry key)
     Clear-Host    clear/cls  Clear the screen
     Clear-Item         cli   Remove content from a variable or an alias
       Get-Command      gcm   Retrieve basic information about a command
   Measure-Command            Measure running time
     Trace-Command            Trace an expression or command
        Add-Computer          Add a computer to the domain
 Checkpoint-Computer          Create a system restore point (XP)
     Remove-Computer          Remove the local computer from a workgroup or domain
    Restart-Computer          Restart the operating system on a computer
    Restore-Computer          Restore the computer to a previous state
       Stop-Computer          Stop (shut down) a computer
Reset-ComputerMachinePassword Reset the machine account password for the computer
 Test-ComputerSecureChannel   Test and repair the secure channel to the domain
     Add-Content         ac   Add to the content of the item
     Get-Content cat/type/gc  Get content from item (specific location)
     Set-Content         sc   Set content in the item (specific location)
   Clear-Content        clc   Remove content from a file/item
         Continue             Skip just this iteration of a loop
     Get-Command        gcm   Get basic information about cmdlets
  Invoke-Command        icm   Run command
   Enable-ComputerRestore     Enable System Restore on a drive
   Disable-ComputerRestore    Disable System Restore on a drive
  Get-ComputerRestorePoint    Get the restore points on the local computer
 Test-Connection              Ping one or more computers
   ConvertFrom-CSV            Convert object properties (in CSV format) into CSV objects
   ConvertTo-CSV              Convert .NET Framework objects into CSV variable-length strings
   ConvertTo-Html             Convert the input into an HTML table
   ConvertTo-Xml              Convert the input into XML
   ConvertFrom-SecureString   Convert a secure string into an encrypted standard string
   ConvertTo-SecureString     Convert an encrypted standard string into a secure string
   Copy-Item     copy/cp/ci   Copy an item from a namespace location
   Export-Counter             Export Performance Counter data to log files
      Get-Counter             Get performance counter data
   Import-Counter             Import performance counter log files
   Get-Credential             Get a security credential (username/password)
   Get-Culture                Get region information (language and keyboard layout)
d
   Get-ChildItem   Dir/ls/gci Get child items (contents of a folder or registry key)
   Get-Date                   Get current date and time
   Set-Date                   Set system time on the host system
   Remove-Item  Del/erase/rd/rm/rmdir   Delete an item
   Compare-Object diff/compare   Compare the properties of objects
     Get-DnsClientCache       Retrieve the content of the local DNS client cache
   Clear-DnsClientCache       Clear the content of the DNS client cache
   Do                         Loop while a condition is True
     Get-DscConfiguration     Get the current config. of a node
     Get-DscLocalConfigurationManager   Get Local Config Manager settings
     Get-DscResource          Get Desired State Config. resources from a computer
     New-DSCCheckSum          Create checksum files for DSC docs/resources
   Start-DscConfiguration     Apply Desired State config to nodes
e
         End                  Function END block
     Get-Event                Get events in the PowerShell event queue
     New-Event                Create a new event
  Remove-Event                Delete events from the event queue
 Unregister-Event             Cancel an event subscription
    Wait-Event                Wait until a particular event is raised
   Clear-EventLog             Delete all entries from an event log
     Get-Eventlog             Get event log data (2003)
   Limit-EventLog             Limit the size of the event log
     New-Eventlog             Create a new event log and a new event source
  Remove-EventLog             Delete an event log
    Show-EventLog             Display an event log
   Write-EventLog             Write an event to an event log
     Get-WinEvent             Get event log data (Vista+)
   Get-EventSubscriber        Get event subscribers
Register-EngineEvent          Subscribe to PowerShell events
Register-ObjectEvent          Subscribe to .NET events
   Register-WmiEvent          Subscribe to a WMI event
   Get-ExecutionPolicy        Get the execution policy for the shell
   Set-ExecutionPolicy        Change the execution policy (user preference)
   Export-Alias         epal  Export an alias list to a file
   Export-Clixml              Produce a clixml representation of PowerShell objects
   Export-Console             Export console configuration to a file
   Export-Csv          epcsv  Export to Comma Separated Values (spreadsheet)
   Exit-PSSession       Exit  Exit PowerShell (or exit a script)
f
   -F operator                Format operator
   Unblock-File               Unblock files downloaded from the Internet
   ForEach-Object    foreach  Loop through each item in the pipeline ( % )
   ForEach                    Loop through each item in a collection
   ForEach method             Loop through each item in a collection
   For                        Loop through items that match a condition
   Format-Custom         fc   Format output using a customized view
   Format-List           fl   Format output as a list of properties, each on a new line
   Format-Table          ft   Format output as a table
   Format-Wide           fw   Format output as a table listing one property only
  Export-FormatData           Save formatting data from the current session 
     Get-FormatData           Get the formatting data in the current session
g
   Get-Item              gi   Get a file/registry object (or any other namespace object)
   Get-ChildItem   dir/ls/gci Get child items (contents of a folder or registry key)
    Backup-GPO                Backup group policy objects (GPOs)
   Restore-GPO                Restore one or all GPOs from a GPO backup
    Import-GPO                Import Group Policy settings into a specified GPO from a GPO backup
h
   Get-Help            help   Open the help file
     Add-History              Add entries to the session history
   Clear-History       clhy   Delete entries from the session history
     Get-History  history/h/ghy Get a listing of the session history
  Invoke-History     r/ihy    Invoke a previously executed Cmdlet
     Get-Host                 Get host information (PowerShell Version and Region)
   Clear-Host      clear/cls  Clear the screen
    Read-Host                 Read a line of input from the host console
   Write-Host                 Write customized output to the host/screen
     Get-HotFix               Get Installed hotfixes
i
   if                         Conditionally perform a command
   Import-Clixml              Import a clixml file and rebuild the PS object
   Import-Csv         ipcsv   Take values from a CSV list and send objects down the pipeline
   Invoke-Command             Run commands on local and remote computers
   Invoke-Expression    iex   Run a PowerShell expression
   Invoke-WebRequest          Get content from a web page
      Get-Item           gi   Get a file object or get a registry (or other namespace) object
   Invoke-Item           ii   Invoke an executable or open a file (START)
      New-Item   md/mkdir/ni  Create a new item in a namespace
   Remove-Item  rm/del/erase/rd/ri/rmdir   Remove an item
      Set-Item           si   Change the value of an item
    Clear-ItemProperty  clp   Remove the property value from a property
     Copy-ItemProperty  cpp   Copy a property along with it's value
      Get-ItemProperty   gp   Retrieve the properties of an object
     Move-ItemProperty   mp   Move a property from one location to another
      New-ItemProperty        Set a new property
   Remove-ItemProperty   rp   Remove a property and its value
   Rename-ItemProperty  rnp   Renames a property at its location
      Set-ItemProperty   sp   Set a property at the specified location to a specified value
j
       Get-Job          gjb   Get PowerShell background jobs that are running
   Receive-Job         rcjb   Get PowerShell background job results
    Remove-Job          rjb   Delete a PowerShell background job
     Start-Job         sajb   Start a PowerShell background job
      Stop-Job         spjb   Stop a PowerShell background job
      Wait-Job          wjb   Wait for a background job
   Job Trigger cmdlets        Get/Set Scheduled job triggers
k
   Stop-Process    kill/spps  Stop a running process
l
Update-List                   Add and remove items from a collection
   Get-Location    pwd / gl   Get and display the current location
   Pop-Location        popd   Set the current working location from the stack
  Push-Location       pushd   Push a location to the stack
   Set-Location  cd/chdir/sl  Set the current working location
m
  Send-MailMessage            Send an email message
   Add-Member                 Add a member to an instance of a PowerShell object
   Get-Member            gm   Enumerate the properties of an object
    Get-Module          gmo   Get the modules imported to the session
 Import-Module         ipmo   Add a module to the session
    New-Module          nmo   Create a new dynamic module (only in memory)
 Remove-Module          rmo   Remove a module from the current session
 Export-ModuleMember          Export specific module members
   Move-Item      mv/move/mi  Move an item from one location to another
o
  Compare-Object diff/compare Compare the properties of objects
    Group-Object       group  Group objects that contain the same value
  Measure-Object              Measure the properties of an object
      New-Object              Create a new .Net object
   Select-Object      select  Select properties of objects
     Sort-Object        sort  Sort objects by property value
    Where-Object              Filter the objects passed along the command pipeline
   Out-Default                Send output to default
   Out-File                   Send output to a file
   Out-GridView         ogv   Send output to an interactive table
   Out-Host              oh   Send output to the host
   Out-Null                   Send output to null
   Out-Printer           lp   Send the output to a printer
   Out-String                 Send objects to the host as strings
p
           Param              Script Parameters
           Pause              Pause and display the message "Press Enter to continue"
           Powershell         Launch a PowerShell session
   Convert-Path        cvpa   Convert a ps path to a provider path
      Join-Path               Combine a path and child-path
   Resolve-Path        rvpa   Resolves the wildcards in a path
     Split-Path               Return part of a path
      Test-Path               Return true if the path exists, otherwise return false
 Get-Pfxcertificate         Get pfx certificate information
    Pop-Location       popd   Set the current working location from the stack
   Push-Location      pushd   Push a location to the stack
         Process              Function PROCESS block
     Get-Process     ps/gps   Get a list of processes on a machine
   Debug-Process              Attach a debugger to a running process
   Start-Process  start/saps  Start one or more processes
    Stop-Process   kill/spps  Stop a running process
    Wait-Process              Wait for a process to stop
   Enable-PSBreakpoint  ebp   Enable a breakpoint in the current console
  Disable-PSBreakpoint  dbp   Disable a breakpoint in the current console
      Get-PSBreakpoint  gbp   Get the currently set breakpoints
      Set-PSBreakpoint  sbp   Set a breakpoint on a line, command, or variable
   Remove-PSBreakpoint  rbp   Delete breakpoints from the current console
      Get-PSDrive       gdr   Get drive information (DriveInfo)
      New-PSDrive   mount/ndr Create a mapped network drive.
   Remove-PSDrive       rdr   Remove a provider/drive from its location
      Get-PSProvider          Get information for the specified provider
      Set-PSdebug             Turn script debugging on or off
  Disable-PSRemoting          Disable remote session configuration on the local computer
   Enable-PSRemoting          Run PowerShell commands on remote computers
    Enter-PSSession  etsn     Start an interactive session with a remote computer
     Exit-PSSession  exsn     End an interactive session with a remote computer
   Export-PSSession  epsn     Import commands and save them in a PowerShell module
      Get-PSSession   gsn     Get the PSSessions in the current session
   Import-PSSession  ipsn     Import commands from another session
      New-PSSession   nsn     Create a persistent connection to a local or remote computer
   Remove-PSSession   rsn     Close PowerShell sessions
    Disable-PSSessionConfiguration  Disable session configurations on the local computer
     Enable-PSSessionConfiguration  Enable session configurations on the local computer
        Get-PSSessionConfiguration  Get the registered PS session configuration
   Register-PSSessionConfiguration  Create and register a new PS session configuration
        Set-PSSessionConfiguration  Change properties of a registered session configuration
 Unregister-PSSessionConfiguration  Delete registered PS session configuration
        New-PSSessionOption         Advanced options for a PSSession
   Add-PsSnapIn        asnp   Add snap-ins to the console
   Get-PsSnapin        gsnp   List PowerShell snap-ins on this computer
   Remove-PSSnapin     rsnp   Remove PowerShell snap-ins from the console
r
   Get-Random                 Get a random number
   Read-Host                  Read a line of input from the host console
   Remove-Item  rm/del/erase/rd/ri/rmdir   Remove an item
   Rename-Item      ren/rni   Change the name of an existing item
   Rename-ItemProperty        Rename a property of an item
   Return                     Exit the current scope, (function, script, or script block)
   Run/Call             &     Run a command (call operator)
s
   Scheduler cmdlets          Get/Set scheduled jobs
   Select-Object     select   Select properties of objects
   Select-XML                 Find text in an XML string or document
   Send-MailMessage           Send an email message
       Get-Service      gsv   Get a list of services
       New-Service            Create a new service
   Restart-Service            Stop and then restart a service
    Resume-Service            Resume a suspended service
       Set-Service            Change the start mode/properties of a service
     Start-Service     sasv   Start a stopped service
      Stop-Service     spsv   Stop a running service
   Suspend-Service            Suspend a running service
   Sort-Object         sort   Sort objects by property value
   Set-StrictMode             Enforce coding rules in expressions & scripts
   Start-Sleep        sleep   Suspend shell, script, or runspace activity
   Switch                     Multiple if statements
   ConvertFrom-StringData     Convert a here-string into a hash table
   Select-String              Search through strings or files for patterns
t
   Tee-Object           tee   Send input objects to two places
   New-Timespan               Create a timespan object
   Trace-Command              Trace an expression or command
   Get-Tracesource            Get components that are instrumented for tracing.
   Set-Tracesource            Trace a PowerShell component
     Start-Transaction        Start a new transaction 
  Complete-Transaction        Commit the transaction
       Get-Transaction        Get information about the active transaction
       Use-Transaction        Add a command or expression to the transaction
      Undo-Transaction        Roll back a transaction
   Start-Transcript           Start a transcript of a command shell session
    Stop-Transcript           Stop the transcription process
         Trap                 Handle a terminating error
         Try ... Catch        Handle a terminating error within a scriptblock
     Add-Type                 Add a .NET Framework type to a PowerShell session
   Update-TypeData            Update extended type configuration
u
   Get-Uiculture              Get the ui culture information
       Unblock-File           Unblock files downloaded from the Internet
   Get-Unique            gu   Get the unique items in a collection
    Update-Formatdata         Update and append format data files
    Update-Help               Download and install help files
    Update-Typedata           Update the current extended type configuration
v
   Clear-Variable       clv   Remove the value from a variable
     Get-Variable        gv   Get a PowerShell variable
     New-Variable        nv   Create a new variable
  Remove-Variable        rv   Remove a variable and its value
     Set-Variable    set/sv   Set a variable and a value
w
Checkpoint-WebApplicationMonitoring Create a checkpoint for an IIS web app
 Get-WebApplicationMonitoringStatus Get the monitoring status of web apps
 New-WebServiceProxy          Create a Web service proxy object
Invoke-WebRequest             Get content from a web page
   Where-Object      where/?  Filter input from the pipeline
   Where method               Filter objects from a collection
   While                      Loop while a condition is True
 Add-WindowsFeature           Install roles, role services, and features
 Get-WindowsFeature           Retrieve roles, role services, and features
 Remove-WindowsFeature        Remove roles, role services, and features
   Write-Debug                Write a debug message to the host display
   Write-Error                Write an object to the error pipeline
   Write-Host                 Display text on screen
   Write-Output   write/echo  Write an object to the pipeline
   Write-Progress             Display a progress bar
   Write-Verbose              Write a string to the host's verbose display
   Write-Warning              Write a string in reverse video to the display
    Set-WmiInstance           Create or update an instance of an existing WMI class
 Invoke-WmiMethod      iwmi   Call WMI methods
    Get-WmiObject      gwmi   Get WMI class information
 Remove-WmiObject      rwmi   Delete an instance of a WMI class
    Connect-WSMan             Connect to the WinRM service on a remote computer
 Disconnect-WSMan             Disconnect from the WinRM service on a remote computer
       Test-WSMan             Test if a computer is setup to receive remote commands
  Invoke-WSManAction          Invoke an action on a specified object
 Disable-WSManCredSSP         Disable Credential Security Service Provider (SSP) authentication
  Enable-WSManCredSSP         Enable Credential SSP authentication
     Get-WSManCredSSP         Get the Credential SSP configuration
   New-WSManInstance          Create a new instance of a management resource
   Get-WSManInstance          Display management information (XML or value)
   Set-WSManInstance          Modify the management information related to a resource
Remove-WSManInstance          Delete a management resource instance
   Set-WSManQuickConfig       Configure the local computer for remote management
   New-WSManSessionOption     Options for WSMan commands
z
   Zipfile                    Compress or Extract zip files
       #                      Comment / Remark
       . (source)             Run a command script in the current shell
       & (call)               Run a command, script or function
       %                      Alias for ForEach-Object
       --%                    Stop parsing input
       ?                      Alias for Where-Object
       $variable = "value"    Define a variable  also: ${n!a#me} = "value"
       $_                     The current pipeline object 
       @(...)                 Force an expression to be evaluated as an array

Slmgr to Change, Remove, or Extend Your Windows License

Windows activation is designed to be as foolproof as possible, so Microsoft’s graphical tools keep it simple. If you want to do something more advanced like remove a product key, force an online activation, or extend the activation timer, you’ll need Slmgr.vbs.
This command line tool is included with Windows, and provides options unavailable in the standard activation interface provided on the Update & Security > Activation screen in the Settings app.
First: Open an Administrator Command Prompt WindowTo use this tool, you’ll want to launch a Command Prompt with Administrator access. To do so on Windows 8 or 10, either right-click the Start button or press Windows+X. Click the “Command Prompt (Admin)” option in the menu that appears. On Windows 7, search the Start menu for “Command Prompt,” right-click it, and select “Run as Administrator.”
View Activation, License, and Expiration Date Information
To display very basic license and activation information about the current system, run the following command. This command tells you the edition of Windows, part of the product key so you can identify it, and whether the system is activated.
slmgr.vbs /dli
To display more detailed license information–including the activation ID, installation ID, and other details–run the following command:
slmgr.vbs /dlv

View the License Expiration Date

To display the expiration date of the current license, run the following command. This is only useful for Windows system activated from an organization’s KMS server, as retail licenses and multiple activation keys result in a perpetual license that won’t expire. If you haven’t provided a product key at all, it’ll give you an error message.
slmgr.vbs /xpr

Uninstall the Product Key

You can remove the product key from your current Windows system with Slmgr. After you run the below command and restart your computer, the Windows system won’t have a product key and will be in an unactivated, unlicensed state.
If you installed Windows from a retail license and would like to use that license on another computer, this allows you to remove the license. It could also be useful if you’re giving that computer away to someone else. However, most Windows licenses are tied to the computer they came with–unless you purchased a boxed copy.
To remove uninstall the current product key, run the following command and then restart your computer:
slmgr.vbs /upk
Windows also stores the product key in the registry, as it’s sometimes necessary for the key to be in the registry when setting up the computer. If you’ve uninstalled the product key, you should run the below command to ensure it’s removed from the registry as well. This will ensure people who use the computer in the future can’t grab the product key.
Running this command alone won’t uninstall your product key. It’ll remove it from the registry so programs can’t access it from there, but your Windows system will remain licensed unless you run the above command to actually uninstall the product key. This option is really designed to prevent the key from being stolen by malware, if malware running on the current system gains access to the registry.
slmgr.vbs /cpky

Set or Change the Product Key

You can use slmgr.vbs to enter a new product key. If the Windows system already has a product key, using the below command will silently replace the old product key with the one you provide.
Run the following command to replace the product key, replacing #####-#####-#####-#####-##### with the product key. The command will check the product key you enter to ensure it’s valid before using it. Microsoft advises you restart the computer after running this command.
You can also change your product key from the Activation screen in the Settings app, but this command lets you do it from the command line.
slmgr.vbs /ipk #####-#####-#####-#####-#####

Activate Windows Online

To force Windows to attempt an online activation, run the following command. If you’re using a retail edition of Windows, this will force Windows to attempt online activation with Microsoft’s servers. If the system is set up to use a KMS activation server, it will instead attempt activation with the KMS server on the local network. This command can be useful if Windows didn’t activate due to a connection or server problem and you want to force it to retry.
slmgr.vbs /ato

Activate Windows Offline

Slmgr also allows you to perform an offline activation. To get an installation ID for offline activation, run the following command:
slmgr.vbs /dti
You’ll now need to get a a confirmation ID you can use to activate the system over the phone. Call the Microsoft Product Activation Center, provide the installation ID you received above, and you’ll be given an activation ID if everything checks out. This allows you to activate Windows systems without Internet connections.
To enter the confirmation ID you’ve received for offline activation, run the following command. Replace “ACTIVATIONID” with the activation ID you’ve received.
slmgr.vbs /atp ACTIVATIONID
Once you’re done, you can use the slmgr.vbs /dli or slmgr.vbs /dlv commands to confirm you’re activated.
This can generally be done from the Activation screen in the Settings app if your PC isn’t activated–you don’t have to use the command if you’d rather use the graphical interface.

Extend the Activation Timer



Some Windows systems provide a limited time where you can use them as free trials before entering a product key. For example, Windows 7 offers a 30-day trial period before it begins complaining at you. To extend this trial period and reset it back to 30 days remaining, you can use the following command.As Microsoft’s documentation puts it, this command “resets the activation timers.”
This command can only be used several times, so you can’t indefinitely extend the trial. The number of time it can be used depends on the “rearm count,” which you can view using the slmgr.vbs /dlv command. It seems different on different versions of Windows–it was three times on Windows 7, and it seems to be five times on Windows Server 2008 R2.
This no longer seems to work on Windows 10, which is very lenient if you don’t provide it a product key anyway. This option still works on older versions of Windows and may continue to work on other editions of Windows, such as Windows Server, in the future.
slmgr.vbs /rearm

Slmgr.vbs Can Perform Actions on Remote Computers, Too

Slmgr normally performs the actions you specify on the current computer. However, you can also remotely administer computers on your network if you have access to them. For example, the first command below applies to the current computer, while the second one will be run on a remote computer. You’ll just need the computer’s name, username, and password.
slmgr.vbs /option
slmgr.vbs computername username password /option

The Slmgr.vbs command has other options, which are useful for dealing with KMS activation and token-based activation.