-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset.ps1
39 lines (33 loc) · 947 Bytes
/
reset.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
[CmdletBinding()]
param(
)
#Requires -RunAsAdministrator
Set-StrictMode -Version 'Latest'
Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath 'PSModules\Carbon' -Resolve)
if( -not (Test-Path -Path 'variable:IsWindows') )
{
$IsWindows = $true
$IsLinux = $false
$IsMacOS = $false
}
$usernames =
Import-LocalizedData -BaseDirectory (Join-Path -Path $PSScriptRoot -ChildPath 'Tests') -FileName 'users.psd1' |
ForEach-Object { $_['Users'] } |
ForEach-Object { $_['Name'] }
foreach( $username in $usernames )
{
if( $IsWindows )
{
Uninstall-CUser -UserName $username
}
else
{
Write-Verbose -Message "Deleting user ""$($username)""."
sudo userdel -r -f $username
}
}
$passwordPath = Join-Path -Path $PSScriptRoot -ChildPath 'Tests\.password'
if( (Test-Path -Path $passwordPath) )
{
Remove-Item -Path $passwordPath -Force
}