ps/Modules/Alkami.PowerShell.SDK/Public/Reset-SDKEnvironment.ps1

99 lines
2.4 KiB
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
function Reset-SDKEnvironment {
<#
.SYNOPSIS
Run the command, answer the quetions, cross your fingers.
.DESCRIPTION
The certificates are left behind. IIS is brittle and things may be funky, this wont always work in some edge cases. Running the same options more than once won't normally result in different behavior from the first time.
.OUTPUTS
A few gigs of space.
.EXAMPLE
$> Reset-SDKEnvironment
$> Remove Alkami C:\Orb directory? (y/n)
$> Remove Alkami IIS Applications? (y/n)
$> Remove Alkami Certificates? (y/n)
$> Remove Alkami Chocolatey packages? (y/n)
$> Remove Alkami Databases? (y/n)
$> Remove Alkami Microservices from Windows Service registry? (y/n)
.EXAMPLE
$> Reset-SDKEnvironment -y
.EXAMPLE
$> Reset-SDKEnvironment @('orb', 'iis', choco', 'database', 'services', 'certs');
.EXAMPLE
$> Reset-SDKEnvironment -Targets @('choco', 'services');
.NOTES
General notes
#>
[CmdletBinding()]
param(
[string[]] $Targets,
[switch]$Experimental
)
if ($Experimental) {
Remove-EnvironmentVariable -Name 'Alkami_SDK_PostInstall_DatabaseConfiguration' -StoreName User
Remove-File -Path "C:\ProgramData\Alkami\SDK\local_installed_version.txt"
}
if(!$Targets) {
}
# https://powershelldoc.sre.alkami.net/Alkami.PowerShell.Common/Alkami.PowerShell.Common/Move-LogsAndDeleteDotNetTemps.html
# https://powershelldoc.sre.alkami.net/Alkami.PowerShell.Common/Alkami.PowerShell.Common/Remove-OldArchivedLogFiles.html
# https://powershelldoc.sre.alkami.net/Alkami.PowerShell.Common/Alkami.PowerShell.Common/Remove-ORBLogFiles.html
Write-Host "Coming Soon!"
if ($Experimental) {
Remove-OrbHostEntries
}
}
Function resetHosts {
$hostsPath = "$env:windir\System32\drivers\etc\hosts";
Get-Content -Path $hostsPath | Where-Object {$_ -contains "#"} | Out-File $hostsPath -append
}
Function resetMachineConfig {
$newContent = ""
foreach ($line in $content){
if($line.length -eq 0 -or $line.Substring(0,1) -eq "#"){
$newContent = $newContent + $line + "`n"
}
}
#Write-Host "New COntent $newContent"
Set-Content -Path $hostsPath -Value $newContent
}
Function resetCerts {
}
Function resetChoco {
}
Function resetIIS {
}
Function resetDatabases {
}
Function resetServices {
}
Function resetOrb {
}