View Get Active Directory user account last logged on time
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
#Check if the account exists. | |
If($Results.Count -eq 0) | |
{ | |
Write-Warning "The SamAccountName '$UserName' cannot find. Please make sure that it exists." | |
} | |
Else | |
{ | |
Foreach($Result in $Results) | |
{ | |
$DistinguishedName = $Result.Properties.Item("DistinguishedName") |
View Script to export the configuration of SQL Server
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
USE master | |
GO | |
PRINT ‘*******************************************************************************************’ | |
PRINT ‘*******************************************************************************************’ | |
PRINT ‘<SQL Server Instance Name>’ | |
SELECT @@SERVERNAME | |
GO | |
PRINT ‘*******************************************************************************************’ | |
PRINT ‘*******************************************************************************************’ | |
PRINT ‘<SQL Server Version, Edition and Build>’ |
View drop database
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
$dbnamefile1 = Get-ChildItem %RestorePath% | Where Name -Match ("DB-Name") | |
$dbname1 = "DB-Name" | |
Restore-SqlDatabase -ServerInstance %SQLSERVER% -Database $dbname1 -BackupFile "%RestorePath%\$dbnamefile1" | |
$dbnamefile2 = Get-ChildItem %RestorePath% | Where Name -Match ("DB-Name") | |
$dbname2 = "DB-Name" | |
Restore-SqlDatabase -ServerInstance %SQLSERVER% -Database $dbname1 -BackupFile "%RestorePath%\$dbnamefile1" | |
$dbnamefile3 = Get-ChildItem %RestorePath% | Where Name -Match ("DB-Name") | |
$dbname3 = "DB-Name" |
View Samba install & configure
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
Install Samba | |
Check for existing samba package if any using the following commands. | |
rpm -qa | grep samba | |
yum list installed | grep samba | |
If samba is installed, remove it using the below command: | |
yum remove samba* | |
Now, install samba using the following command. |
View export single IIS site
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
%windir%\system32\inetsrv\appcmd list site "site" /config /xml > c:\mywebsite.xml |
View Install MongoDB as a Service on Windows 2012
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
mongod --dbpath "C:\Program Files\MongoDB\Server\3.4\database" --logpath "C:\Program Files\MongoDB\Server\3.4\logs" --install --serviceName "MongoDB Server" |
View MongoDB dump
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
mongodump -h localhost -c New Collection -o F:\mongodb_backup\Dest_SingleCollBkp |
View PS script to MongoDB dump
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
$date = Get-Date -UFormat %Y-%m-%d; | |
$backupFolder = $date; | |
$basePath = "F:\mongodb_backup"; | |
$destinationPath = Join-Path $basePath $backupFolder; | |
if(!(Test-Path -Path $destinationPath)) { | |
New-Item -ItemType directory -Path $destinationPath; | |
(C:\mongodump.exe --out $destinationPath); | |
} |
View PS Transfer files into FTP
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
#we specify the directory where all files that we want to upload | |
$Dir="C:/Dir" | |
#ftp server | |
$ftp = "ftp://xxx.xxx.xxx/dir/" | |
$user = "user" | |
$pass = "Pass" | |
$webclient = New-Object System.Net.WebClient | |
View Duplicati CommandLine restore
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
C:\Program Files\Duplicati 2\Duplicati.CommandLine.exe restore %SftpURL% --auth-username=%SftpUser% --auth-password=%SftpPassword% --passphrase=%SftpPassphrase% --restore-path=%RestorePath% |
OlderNewer