Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following command is a PowerShell script designed to activate Windows and Microsoft Office 2010 Home and Business. My coworker is trying to figure out

The following command is a PowerShell script designed to activate Windows and Microsoft Office 2010 Home and Business. My coworker is trying to figure out what to do to make the system run faster so it can activate faster. Where in this script do I need to change to make this work?

#region Partition

Write-Progress -Activity 'Computer Setup' -Status 'Resizing C Drive' -PercentComplete 5

$size = (Get-PartitionSupportedSize -DriveLetter c).sizemax

Resize-Partition -DriveLetter c -Size $size

$adjsize = [Math]::Round(($size / 1GB)*1.07374)

#endregion

#region Define Directories

function Set-Directory

{

$test1 = Test-Path "C:\Program Files (x86)\Microsoft Office\Office14\ospp.vbs"

$dir1 = "C:\Program Files (x86)\Microsoft Office\Office14"

$test2 = Test-Path "C:\Program Files\Microsoft Office\Office14\ospp.vbs"

$dir2 = "C:\Program Files\Microsoft Office\Office14"

if($test1 -eq $true) {$cd = cd $dir1}

if($test2 -eq $true) {$cd = cd $dir2}

}

cd C:\Windows\System32

#endregion

#region Activate Office

Write-Progress -Activity 'Computer Setup' -Status 'Registering Office' -PercentComplete 15

Set-Directory

$stat = cscript ospp.vbs /dstatus

$hide = $stat.ToCharArray()

$split = $stat.split(" ")

$info = $split.Contains("---LICENSED---")

if($info -ne $true){

Do{

Write-Progress -Activity 'Computer Setup' -Status 'Registering Office' -PercentComplete 20

[void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')

$title = 'Microsoft Office Registration'

$msg = 'Enter your Office Key With Dashes:'

$officekey = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title)

cscript ospp.vbs /inpkey:"$officekey"

cscript ospp.vbs /act

$stat = cscript ospp.vbs /dstatus

$hide = $stat.ToCharArray()

$split = $stat.split(" ")

$info = $split.Contains("---LICENSED---")

if($info -ne $true)

{$wshell = New-Object -ComObject Wscript.Shell

$wshell.Popup("Key failed to activate. Please ensure you are including the dashes in the product key and have internet connectivity.",0,"C2SDK",0x0)}

}while($info -ne $true)

}

$wshell = New-Object -ComObject Wscript.Shell

$wshell.Popup("Microsoft Office was successfully activated",0,"C2SDK",0x0)

cd C:\Windows\System32

#endregion

#region Activate Windows 10 Product Key

cd C:\Windows\System32

$winstat = cscript slmgr.vbs /dli

$hide2 = $winstat.ToCharArray()

$winsplit = $winstat.split(",")

$wininfo = $winsplit.contains("License Status: Licensed")

if($wininfo -ne $true){

Write-Progress -Activity 'Computer Setup' -Status 'Registering Windows' -PercentComplete 50

do{

Write-Progress -Activity 'Computer Setup' -Status 'Registering Windows' -PercentComplete 60

[void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')

$title = 'Windows 10 Activation'

$msg = 'Enter your Windows 10 Product Key Need to Include Dashes:'

$win10key = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title)

cscript slmgr.vbs /ipk "$win10key"

cscript slmgr.vbs /ato

$winstat = cscript slmgr.vbs /dli

$hide2 = $winstat.ToCharArray()

$winsplit = $winstat.split(",")

$wininfo = $winsplit.contains("License Status: Licensed")

if($wininfo -ne $true)

{$wshell = New-Object -ComObject Wscript.Shell

$wshell.Popup("Key failed to activate. Please ensure you are including the dashes in the product key and have internet connectivity.",0,"C2SDK",0x0)}

} while ($wininfo -ne $true)

}

$wshell = New-Object -ComObject Wscript.Shell

$wshell.Popup("Windows 10 Successfully Activated",0,"C2SDK",0x0)

#endregion

#region Enter Computer Number

Write-Progress -Activity 'Computer Setup' -Status 'Changing Computer Name' -PercentComplete 75

#enter desired computer name

[void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')

$title = 'Change Computer Number'

$msg = 'Enter Desired Five Digit Computer Number:'

$Compname = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title)

#endregion

#region Retrieve System Info for Flash Drive

Write-Progress -Activity 'Computer Setup' -Status 'Gathering Computer Info' -PercentComplete 90

#Get Processor

$Processor = (Get-WmiObject -class win32_processor | Select-Object name).name

#Get RAM

$UglyPhysicalRAM = Get-WmiObject win32_computersystem | select totalphysicalmemory

$RAMGB = [Math]::Round(($uglyphysicalram.TotalPhysicalMemory/ 1GB))

#Get Hard Drive Size

$Disksize = $adjsize

#Get CD/DVD Hardware Type

$CDDrive = (Get-WmiObject win32_cdromdrive | select manufacturer).manufacturer

#Get Computer Model

$Model = (Get-WmiObject win32_computersystem | select model).model

$Manufacturer = (Get-WmiObject win32_computersystem | select manufacturer).manufacturer

$MakeAndModel = "$Manufacturer"+" "+"$model"

#endregion

#region Add Information to Flash Drive

$flashpath = Get-WmiObject win32_volume -Filter "drivetype=2"| where-object {$_.label -eq "C2SDK"}| select -expand driveletter

$BackupPath = $Flashpath + "\" + "ComputerInfo.csv"

$NewCsvLine = "{0},{1},{2},{3},{4},{5},{6},{7}" -f $Compname,$win10key,$officekey,$CDDrive,$Disksize,$MakeAndModel,$RAMGB,$Processor

$NewCsvLine | add-content -path $BackupPath

#endregion

#region Change Computer Name and Restart

$fullname = "C2KSD"+"-"+"$Compname"

rename-computer $fullname

$wshell = New-Object -ComObject Wscript.Shell

$wshell.Popup("This computer has been successfully setup and will restart when you click ok.",0,"C2SDK",0x0)

restart-computer

#endregion

#region Random Thoughts

<#

lock script

cant change excel name

flash drive needs to be named C2SDK

doesnt show na for no cd

if model has a -/, it gets messed up

if only office or win10 gets activated it will still create an excel entry with only 1 product key

#>

<# Hide PS Window

$t = '[DllImport("user32.dll")] public static extern bool ShowWindow(int handle, int state);'

add-type -name win -member $t -namespace native

[native.win]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0)

#>

#endregion

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

2. What are the different types of networks?

Answered: 1 week ago