GoogleCloudPlatform / database-assessment

Database Migration Assessment
https://googlecloudplatform.github.io/database-assessment/
Apache License 2.0
62 stars 35 forks source link

feat: Adding dmaSQLServerHWSpecs.ps1 to collect the HW Shape info #311

Closed liozme closed 10 months ago

liozme commented 11 months ago

dmaSQLServerHWSpecs.ps1 collects amount of cores and total memory capacity in bytes from the machineName in SQL collect script.

I've tested it on 2 labs, it has a prerequisite of access of WMI from where the script is being run, if it fails it should only log a failure and not fail the collection script.

I've ran the make build then copied the zip into a windows machine and ran it against another windows machine with MSSQL server

output csv:

"pkey"|"dma_source_id"|"dma_manual_id"|"computer_name"|"cores"|"memory_bytes"
"WIN-U6S28Q6HGOB_master_MSSQLSERVER_102923052805"|"WIN-U6S28Q6HGOB_33758EFA592E405990C30073089AD701_MSSQLSERVER"|"NA"|"WIN-U6S28Q6HGOB"|"4"|"8589934592"
liozme commented 11 months ago

@shane-borden @cofin - I've created a PR to collect HW shape. WDYT?

cofin commented 11 months ago

@liozme, I don't know that I have too much to add on this one. It looks good to me.

Just to confirm - the following switch ensures that we will only get the prompt when the user the pre-existing $machinename variable doesn't match the current $COMPUTERNAME?

Call is here and the block I'm referring to is here:

    $credential = $null
    # This will create a pop up for the user to enter credentials for shape sizing collection.
    if ($computerName -ne $env:COMPUTERNAME) {
        Write-Host "Identified a remote computer, please add credentials"
       $credential = Get-Credential -Message "Please enter system credentials for machine shape sizing:"
    }

Since this will be a required script for SQL Server, we should make sure the prompting is as minimal as possible.

Also, I know that we talked about it, but I don't remember where we landed on this. My guess is this likely does not require any additional privileges for local executions since we currently list "Administrator Mode" as a requirement?

I really appreciate the help on this one, and nice work!

liozme commented 11 months ago

@cofin, to your question, yes if $machineName != $env:ComputerName (i checked and -eq is ignore case equal). it will ask the user for credentials. Another solution is to try without credentials for the Wmi-GetObject. The default is to use current credentials. If that fails, ask for credentials.

liozme commented 11 months ago

MY assumption here was: this script only works if MSSQL is on windows and the script is never called otherwise. if that is not the case (Azure/AWS/Linux), we should add some sort of condition not to call it.