Skip to content

Instantly share code, notes, and snippets.

View spy86's full-sized avatar
🎯
Focusing

Maciej Michalski spy86

🎯
Focusing
View GitHub Profile
#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")
USE master
GO
PRINT ‘*******************************************************************************************’
PRINT ‘*******************************************************************************************’
PRINT ‘<SQL Server Instance Name>’
SELECT @@SERVERNAME
GO
PRINT ‘*******************************************************************************************’
PRINT ‘*******************************************************************************************’
PRINT ‘<SQL Server Version, Edition and Build>’
@spy86
spy86 / drop database
Created August 3, 2017 10:03
PS drop database & close connection
$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"
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.
%windir%\system32\inetsrv\appcmd list site "site" /config /xml > c:\mywebsite.xml
mongod --dbpath "C:\Program Files\MongoDB\Server\3.4\database" --logpath "C:\Program Files\MongoDB\Server\3.4\logs" --install --serviceName "MongoDB Server"
mongodump -h localhost -c New Collection -o F:\mongodb_backup\Dest_SingleCollBkp
$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);
}
#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
C:\Program Files\Duplicati 2\Duplicati.CommandLine.exe restore %SftpURL% --auth-username=%SftpUser% --auth-password=%SftpPassword% --passphrase=%SftpPassphrase% --restore-path=%RestorePath%