Code Monkey home page Code Monkey logo

functions's Introduction

Functions

Contains useful functions that I use and am able to share.

Get-DriveSize - Returns the Drive or Volume Name, Label, Size in Gb, Free Space in GB and Free space as a percentage of drives and mount points on local and remote servers

Test-SQLDefault - Runs a series of Pester tests against a SQL Instance or an array of SQL Instances. Should be easy to customise to your own environments required defaults

Show-DatabasesOnServer - Returns the Name and sizes of databases on a server or array of servers

Set-OlaJobSchedule - Sets the agent job schedule for the jobs created by Ola Hallengrens Maintenance plan

When-WillSQLComplete - Quick function to check progress of SQL Commands via sys.dm_exec_requests. Useful for DBCC, Backup, Restore and indexing progress

Test-OLAInstance - Wrapper to call a Pester Test script Test-OLA to test Ola Hallengren Maintenance Solution is installed correctly

functions's People

Contributors

fatherjack avatar mattlorimor avatar sqldbawithabeard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

functions's Issues

Failover Cluster mudule name on Server 2016

Thanks for sharing your scripts.
Did pick up something funny where the check for the FailoverCluster module. Line

On a Windows Server 2016, once the "Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools" is executed. The module is named FailoverClusters not FailoverCluster

Issue with FailoverCluster(s) error-handling

Hello! First off, thank you for this and all other incredibly useful functions you've written.

I've found an issue with this spot of error handling at the end of this function (starting at line 2016):

Function Get-TheModule { Get-Module FailoverCluster } if(-Not(Get-TheModule)){ Write-Warning "Sorry you dont have the failover cluster module installed so wont be abel to get the cluster log" Write-Warning "You will need to run Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools"

Correct me if I'm wrong, but "FailoverCluster" should be replaced with "FailoverClusters." I ran these commands to confirm:

C:> Get-Command -Module FailoverClusters | Measure | Select Count

Count : 120

Please let me know if I'm mistaken with anything here.

Doesn't proceed after installing Failover-Clustering

I have installed the Failover-Clustering as requested. But still fails the check on the Get-module to see if the Failover Clustering exists. Output below from the PS window.

PS C:\Program Files\WindowsPowerShell\Modules\dbatools\functions> Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools

Success Restart Needed Exit Code Feature Result


True No NoChangeNeeded {}

PS C:\Program Files\WindowsPowerShell\Modules\dbatools\functions> $InstallationFolder = 'C:\Program Files\WindowsPowerShell\Modules\FailoverDetection'
$DownloadFolder = 'C:\Program Files\WindowsPowerShell\Modules\FailoverDetection'
$DataFolder = 'C:\Program Files\WindowsPowerShell\Modules\FailoverDetection\Data'
$SQLInstance = 'USPPDW-SQLN01'

$invokeSqlFailOverDetectionSplat = @{
    DownloadFolder = $DownloadFolder
    SQLInstance = $SQLInstance
    DataFolder = $DataFolder
    InstallationFolder = $InstallationFolder
    AlreadyDownloaded = $false
    Analyze = $true
    Show = $true
}
Invoke-SqlFailOverDetection @invokeSqlFailOverDetectionSplat -WhatIf

WARNING: Sorry you dont have the failover cluster module installed so wont be abel to get the cluster log
WARNING: You will need to run Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools

PS C:\Program Files\WindowsPowerShell\Modules\dbatools\functions>

Failover Cluster module name on Server 2016

Thanks for sharing your scripts.
Did pick up something funny where the check for the FailoverCluster module. Line

On a Windows Server 2016, once the "Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools" is executed. The module is named FailoverClusters not FailoverCluster

Failed to create catalog item: The remote server returned an error: (422) Unprocessable Entity.

Hey, SQLDBAWithABeard! Can you help me?

Write-RsRestCatalogItem : System.Exception: Failed to create catalog item: The remote server returned an error: (422) Unprocessable Entity. --->
System.Net.WebException: The remote server returned an error: (422) Unprocessable Entity.
at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
--- End of inner exception stack trace ---
At C:\Users\loren\Downloads\deploy_pbix_reports.ps1:162 char:13

  •         Write-RsRestCatalogItem -WebSession $session -Path $PBIXF ...
    
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-RsRestCatalogItem

SQL Defaults Check

Hi

First of all, thanks for sharing the code.

Some suggestions to the script:

  • Get-CIMInstance predicts the use of sessions, so to reduce authentication overhead you could use Get-CIMSession and use that
  • Get-Service status can be joined with equivalent Win32_Service call and then Pester the resulting properties separately
  • Both services can be queried at the same time
  • Get-CIMSession can be added in the server connectivity to check for server connectivity
  • Invoke-Command should also be tested at this level for WinRM staus (I think there are other ways to check through CIM)
  • You forgot named instances :P

I know this is just a community sample and as such you might have this implemented in your own scripts, but as "The" SQL Server guy to go on PowerShell :) it would be great that the first 5 could reach the community.

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.