This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########### | |
## SETUP ## | |
########### | |
## get some data into xlsx files :) | |
$svr = Connect-DbaInstance -SqlInstance mssql1 -SqlCredential (Get-Credential) | |
foreach ($tbl in (Get-DbaDbTable -SqlInstance $svr -Database AdventureWorks2017 | where schema -eq 'sales' | select -first 10)){ | |
Invoke-DbaQuery -SqlInstance $svr -Database AdventureWorks2017 -Query "Select top 10 * from $($tbl.Schema).$($tbl.name)" | | |
Export-Excel -Path "c:\temp\excel\$($tbl.name).xlsx" -ExcludeProperty ItemArray, RowError, RowState, Table, HasErrors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source for xlsx files | |
$SourceFolder = 'C:\Folder' | |
# Destination folder for where the csvs will go | |
$DestFolder = 'C:\Folder\csv' | |
# Foreach Excel file, read it in and then export to CSV with the same name. | |
Get-ChildItem $SourceFolder -Filter *.xlsx | | |
ForEach-Object { Import-Excel $_.FullName | Export-Csv -Path ("{0}\{1}.csv" -f $DestFolder, $_.basename) -NoTypeInformation } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source for xlsx files | |
$SourceFolder = 'C:\Folder' | |
# Destination folder for where the csvs will go | |
$DestFolder = 'C:\Folder\csv' | |
# Foreach Excel file, read it in and then export to CSV with the same name. | |
Get-ChildItem $SourceFolder -Filter *.xlsx | | |
ForEach-Object { Import-Excel $_.FullName | Export-Csv -Path ("{0}\{1}.csv" -f $DestFolder, $_.basename) -NoTypeInformation } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$SQLSvcMSA = 'DOMAIN\MSASQLName$' | |
$AgtSvcMSA = 'DOMAIN\MSAAgentName$' | |
# These are required but not used since we are using MSAs | |
$SQLSvcAccount = New-Object System.Management.Automation.PSCredential($SQLSvcMSA, $('mypassword' | ConvertTo-SecureString -asPlainText -Force)) | |
$AgtSvcAccount = New-Object System.Management.Automation.PSCredential($AgtSvcMSA, $('mypassword' | ConvertTo-SecureString -asPlainText -Force)) | |
Configuration ServerBuild { | |
Import-DscResource -ModuleName 'PSDscResources' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$servers = Get-DbaRegServer -SqlInstance CmsServerName | |
$os = Get-DbaOperatingSystem -ComputerName $servers.name | |
$sql = Get-DbaProductKey -ComputerName $servers.name | |
$excelFile = C:\temp\VersionInfo.xlsx' | |
$osProps = 'ComputerName','Architecture','Version','Build','OSVersion', 'SPVersion', 'InstallDate','LastBootTime', 'ActivePowerPlan' | |
$sqlProps = 'ComputerName','InstanceName','SqlInstance','Version','Edition' | |
$osExcel = @{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module dbatools | |
Get-DbaDatabase -SqlInstance Server1 |
NewerOlder