This file contains hidden or 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
@echo off | |
setlocal | |
set "SERVICE_NAME=service_name" | |
:: Check if the service exists using PowerShell | |
for /f "delims=" %%i in ('powershell -Command "$service = Get-Service -Name '%SERVICE_NAME%' -ErrorAction SilentlyContinue; if ($null -eq $service) { Write-Output 'NotExists' } else { Write-Output 'Exists' }"') do set "SERVICE_EXISTS=%%i" | |
if "%SERVICE_EXISTS%"=="NotExists" ( | |
echo The service %SERVICE_NAME% does not exist. |
This file contains hidden or 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
# Define variables | |
$searchString = "Error" # The string to search for in event logs | |
$since = (Get-Date).AddDays(-1) # Only events from the last day | |
$outputFile = "C:\Path\To\Your\events.csv" # Specify your output file path | |
# Prepare the CSV file | |
if (Test-Path $outputFile) { | |
Remove-Item $outputFile -Force # Delete existing file if it exists | |
} |
This file contains hidden or 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
@echo off | |
setlocal EnableDelayedExpansion | |
if "%~3"=="" ( | |
echo Incorrect usage. The correct usage is: %~nx0 "Search Directory" "Filename Pattern" "Search String" | |
exit /b | |
) | |
This file contains hidden or 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
@echo off | |
setlocal EnableDelayedExpansion | |
set "FOLDER_PATH=D:\Software\FAF\Logs\lex" | |
set "TEMP_FILE=%TEMP%\temp_results.txt" | |
if exist "%TEMP_FILE%" del "%TEMP_FILE%" |
This file contains hidden or 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
<# | |
.SYNOPSIS | |
Collect-ServerInfo.ps1 - PowerShell script to collect information about Windows servers | |
.DESCRIPTION | |
This PowerShell script runs a series of WMI and other queries to collect information | |
about Windows servers. | |
.OUTPUTS | |
Each server's results are output to HTML. |
This file contains hidden or 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
CREATE FUNCTION [dbo].[fn_ConsecutiveNumbers] | |
( | |
@start int, | |
@end int | |
) RETURNS TABLE | |
RETURN | |
select | |
x268435456.X | |
| x16777216.X |
This file contains hidden or 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
--To search all columns of all tables in Pubs database for the keyword "Computer" | |
EXEC SearchAllTables 'Computer' | |
GO | |
Here is the complete stored procedure code: | |
CREATE PROC SearchAllTables | |
( | |
@SearchStr nvarchar(100) |
This file contains hidden or 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
WHENEVER SQLERROR EXIT SQL.SQLCODE | |
SET ECHO ON | |
/ | |
set autocommit on | |
DEF username = &1 | |
--DEF pwd = &2 | |
/ | |
DEF default_ts = users | |
/ |
This file contains hidden or 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
This is the list of exit codes for wget: | |
0 No problems occurred | |
1 Generic error code | |
2 Parse error — for instance, when parsing command-line options, the .wgetrc or .netrc… | |
3 File I/O error | |
4 Network failure | |
5 SSL verification failure | |
6 Username/password authentication failure | |
7 Protocol errors |
This file contains hidden or 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
--Listing 9-27. Index Defragmantion Script Template | |
DECLARE @MaxFragmentation TINYINT=30 | |
,@MinimumPages SMALLINT=1000 | |
,@SQL nvarchar(max) | |
,@ObjectName NVARCHAR(300) | |
,@IndexName NVARCHAR(300) | |
,@CurrentFragmentation DECIMAL(9, 6) | |
DECLARE @FragmentationState TABLE | |
( | |
SchemaName SYSNAME |
NewerOlder