Windows Service - Stop
Stop-Service -name "SiteHawk.AcquireProcessor_DR"
#in a pipeline, use variables for the service name:
Stop-Service -name $(AcquireServiceName)
Windows Service - Delete
#Run the Remove-Service cmdlet with the name of your service as an argument:
Remove-Service -Name "YourServiceName"
#After the executable for a service is deleted, the service might still be present in the registry. If that's the case, use the command sc delete to remove the entry for the service from the registry.
sc.exe delete "YourServiceName"
Windows Service - Set To Manual
Set-Service "SiteHawk.AcquireProcessor_DR" -StartupType Manual
Windows Service - Filter and Sort by Status
Get-Service "sitehawk*" | Sort-Object status
Join VM to Domain
$machinename = 'Name of VM';
$domainname = 'name o domain';
$dcname = 'name od domain controller';
$domainUserName = 'domain/username';
$domainUserPassword = 'domain user password';
netdom join $machinename /domain:$domainname /dcname:$dcname /ud:$domainUserName /pd:$domainUserPassword
Install SSL Cert on IIS
#--Isntall Cert for IIS
$password = ConvertTo-SecureString -String "$(CERT_PASS)" -AsPlainText -Force
Import-PfxCertificate -FilePath "$(CERT_PATH)" -Password $password -Exportable -CertStoreLocation #Cert:\LocalMachine\Personal\
#Import Cert to Local Machine:
Get-Command -Module PKI
$certfile = "F:\Certificates\SiteCerts\$(PFX_FILE_NAME)"
$password= "$(CERT_PASS)" | ConvertTo-SecureString -AsPlainText -Force
#LocalMachine - Personal
Import-PfxCertificate -FilePath $certfile -CertStoreLocation Cert:\localMachine\my -Password $password
#Install Cert - LocalMachine - Root
Import-PfxCertificate -FilePath $certfile -CertStoreLocation Cert:\localMachine\root -Password $password
Delete Old Files - Keep last 3 folders
clear
$path = "C:\Applications\<folder>\<subfoder>"
$counter = 0
$temp = ""
$resultsArray = @()
$folders = Get-ChildItem $path -Directory | sort LastWriteTime -Descending
foreach ($folder in $folders) {
if($counter -gt 2){
#$temp = ("{0}\{2}" -f $path,$folder)
$temp = $path
$temp += "\"
$temp += $folder
$temp
Remove-Item $temp -Recurse
}
$counter++
}