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
#Searches for files with the Latin 1 Supplement letters in the given directory | |
$table = @{Expression={$_.Name};Label="Name";width=20},@{Expression={$_.Directory};Label="Directory";width=50},@{Expression={$_.CreationTime};Label="Creation Date";width=25},@{Expression={$_.LastWriteTime};Label="Last Modification Date";width=25},@{Expression={$_.Length};Label="File Size";width=10} | |
Get-childItem "\\server1\FileShare" -Recurse | Where {$_.Name -match "[\u00C0-\u00FF]" -AND $_.Attributes -notlike "*Directory*"} | format-table $table |
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
#Verify IIS Settings using PowerShell v3 | |
Import-Module Webadministration | |
$appName = (Get-ChildItem -Path IIS:\apppools).name | |
foreach($appPool in $appName) | |
{ | |
#Rapid Fail Protection | |
$rapid = (Get-Item "IIS:\AppPools\$appPool").failure.rapidFailProtection | |
if (!($rapid -eq "True")) | |
{Write-Host "Error: The rapid fail protection for $appPool is $rapid." -ForegroundColor Yellow} |
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
EXEC sp_MSForEachDB ' Use [?]; SELECT DB_NAME() AS ''Database Name''; | |
Select * | |
FROM sys.sql_modules m | |
INNER JOIN sys.objects o ON m.object_id=o.object_id | |
INNER JOIN sys.schemas s ON o.schema_id=s.schema_id | |
WHERE m.definition Like ''%xp_cmdshell%'' | |
ORDER BY 1' |
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
$thisPsSession = New-PSSession "Server1" | |
Invoke-Command -Session $thisPsSession -ScriptBlock { | |
sqlcmd.exe -q "SELECT yourcolumn FROM yourdatabase" | |
} | |
Remove-PSSession $thisPsSession |
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
--Find a prexisting email profile to be inserted into the "@profile_name" variable below | |
EXEC msdb.dbo.sysmail_help_profile_sp; | |
--Define the text you will email | |
DECLARE @body NVARCHAR(MAX) | |
SET @body = 'Whatever you want to send yourself' | |
--Send the email using the email profile found | |
EXEC msdb.dbo.sp_send_dbmail | |
@profile_name = 'Administrator Profile', | |
@recipients = 'administrator@youremail.com', | |
@body = @body, |
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
$thisPsSession = New-PSSession SERVER1 | |
Invoke-Command -Session $thisPsSession -ScriptBlock { | |
Set-ExecutionPolicy RemoteSigned | |
} |
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
#Deleting Sites and app pools in IIS 7 with PowerShell | |
$appCmd = "C:\windows\system32\inetsrv\appcmd.exe" | |
#lists all the sites | |
& $appcmd list site | |
#deletes a specific site | |
& $appcmd delete site "Name of site" | |
#deletes a specific application pool | |
& $appcmd delete apppool "Name of app pool" | |
#delete any app pools that use a certain username (in the identity column of the GUI) |
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
#Purpose: Start background jobs on multiple servers at the same time and wait until they finish | |
$servers = "server1","server2","server3" | |
$buildNumber = "1.2" | |
$servers | %{ | |
$script = | |
{ | |
param($server) | |
Invoke-Command -ComputerName $server -ScriptBlock {param($buildNumber) New-Item c:\Deployment\$buildNumber -type directory -force} |
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
<# | |
.NOTES | |
Name: Get-CertSettings.ps1 | |
Author: Davina Fournier | |
Requires: PowerShell v3 or higher. The account running this script needs to have rights to access IIS settings on the target servers. Tested on 2012 servers in a single domain. | |
Last Updated: 7/31/2016 | |
.SYNOPSIS | |
Retrieves all websites from IIS. Prints the hostname of the target server, the website name, whether or not SSL is enabled, the certificate expiration date, the certificate subject and the certificate subject alternative names (for multi-domain certificates). | |
.DESCRIPTION | |
A list of remote computer names should be entered into the Server_list.txt file currently located in the "Tools\Scripts" directory. The script creates a session to each remote computer, then queries IIS for the binding settings of each website. If the website has no SSL binding, then the "SSL Enabled" setting will be set to "Not Enabled" and the remaining values will be empty. If there is a SSL binding, the Local Machine stores are searched for the corresponding certif |
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
$serverName = "SQL1" ###name of the SQL instance, not the server name | |
$jobQuery = "select jobs.name from msdb.dbo.sysjobs jobs (nolock) | |
join msdb.dbo.syscategories categories (nolock) | |
on jobs.category_id = categories.category_id | |
where jobs.name like '$servername-YourReplicationName%' AND categories.name = 'REPL-Merge'"###Used for merge replication but can be changed | |
$jobQuery = (Invoke-Sqlcmd -ServerInstance $serverName -Query $jobQuery | Select-Object -Property name).name | |
$jobQuery | Out-File c:\logs\database\replication__sync_log.txt -Append | |
foreach ($row in $jobQuery) | |
{ |
OlderNewer