Test Instant File Initialization Command
Summarize Command's Functionality
Command to test to see if IFI is enable for the service account.
Is there a command that is similiar or close to what you are looking for?
No
Technical Details
Command exist to Get-DbaPrivilege and Set-DbaPrivilege, maybe one to just test like we do Power Plans since it is a recommended setting? I use this code to set if doesn't exist
$s = "server1"
$service = Get-DbaService -ComputerName $s | Where-Object { $_.ServiceType -eq "Engine" }
$priv = Get-DbaPrivilege -ComputerName $s | Where-Object { $_.InstantFileInitialization -eq $false -and $_.User -eq $service.StartName }
if (!$priv) {
Set-DbaPrivilege -ComputerName $s -Type IFI
}
Get-DbaPrivilege -ComputerName $s | Where-Object { $_.InstantFileInitialization -eq $false -and $_.User -eq $service.StartName } | Format-Table
that makes sense. what do you propose the command name to be?
First I thought about Test-DbaPrivilege with a parameter Privilege, but as we only have a solid best practice for InstantFileInitialization I now think Test-DbaInstantFileInitialization will be best. The hint to Test-DbaPowerPlan is very good, we can have a similar output. As input I would vote for ComputerName to test all instance on that computer and output one object per instance.
Example code:
function Test-DbaInstantFileInitialization {
param(
[DbaInstance[]]$ComputerName = $env:COMPUTERNAME,
[PSCredential]$Credential,
[switch]$EnableException
)
foreach ($computer in $ComputerName) {
$services = Get-DbaService -ComputerName $computer -Credential $Credential -Type Engine
$privileges = Get-DbaPrivilege -ComputerName $computer -Credential $Credential
foreach ($service in $services) {
$instantFileInitialization = ($privileges | Where-Object User -eq $service.StartName).InstantFileInitialization
$isBestPractice = $instantFileInitialization -eq $true
[PSCustomObject]@{
ComputerName = $service.ComputerName
ServiceName = $service.ServiceName
InstanceName = $service.InstanceName
User = $service.StartName
InstantFileInitialization = $instantFileInitialization
IsBestPractice = $isBestPractice
}
}
}
}
Example output:
@tboggiano What do you think about the proposed command?