Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $version = "Version 2.5.1"
- # $ErrorActionPreference = 'SilentlyContinue'
- #=====[ Initial Settings
- # Set script name
- $host.ui.RawUI.WindowTitle = "Asylum. $version"
- # Hide script from the team member to run this script in the background - Disabled during testing
- $t = '[DllImport("user32.dll")] public static extern bool ShowWindow(int handle, int state);'
- add-type -name win -member $t -namespace native
- [native.win]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0)
- #=====[ Load Functions
- function ConvertTo-HexString {
- [CmdletBinding()]
- param (
- # Value to convert
- [Parameter(Mandatory=$true, Position = 0, ValueFromPipeline=$true)]
- [object] $InputObjects,
- # Delimiter between Hex pairs
- [Parameter (Mandatory=$false)]
- [string] $Delimiter = ' ',
- # Encoding to use for text strings
- [Parameter (Mandatory=$false)]
- [ValidateSet('Ascii', 'UTF32', 'UTF7', 'UTF8', 'BigEndianUnicode', 'Unicode')]
- [string] $Encoding = 'Default'
- )
- begin {
- function Transform ([byte[]]$InputBytes) {
- [string[]] $outHexString = New-Object string[] $InputBytes.Count
- for ($iByte = 0; $iByte -lt $InputBytes.Count; $iByte++) {
- $outHexString[$iByte] = $InputBytes[$iByte].ToString('X2')
- }
- return $outHexString -join $Delimiter
- }
- ## Create list to capture byte stream from piped input.
- [System.Collections.Generic.List[byte]] $listBytes = New-Object System.Collections.Generic.List[byte]
- }
- process
- {
- if ($InputObjects -is [byte[]])
- {
- Write-Output (Transform $InputObjects)
- }
- else {
- foreach ($InputObject in $InputObjects) {
- [byte[]] $InputBytes = $null
- if ($InputObject -is [byte]) {
- ## Populate list with byte stream from piped input.
- if ($listBytes.Count -eq 0) {
- Write-Verbose 'Creating byte array from byte stream.'
- Write-Warning ('For better performance when piping a single byte array, use "Write-Output $byteArray -NoEnumerate | {0}".' -f $MyInvocation.MyCommand)
- }
- $listBytes.Add($InputObject)
- }
- elseif ($InputObject -is [byte[]])
- {
- $InputBytes = $InputObject
- }
- elseif ($InputObject -is [string])
- {
- $InputBytes = [Text.Encoding]::$Encoding.GetBytes($InputObject)
- }
- elseif ($InputObject -is [bool] -or $InputObject -is [char] -or $InputObject -is [single] -or $InputObject -is [double] -or $InputObject -is [int16] -or $InputObject -is [int32] -or $InputObject -is [int64] -or $InputObject -is [uint16] -or $InputObject -is [uint32] -or $InputObject -is [uint64])
- {
- $InputBytes = [System.BitConverter]::GetBytes($InputObject)
- }
- elseif ($InputObject -is [guid])
- {
- $InputBytes = $InputObject.ToByteArray()
- }
- elseif ($InputObject -is [System.IO.FileSystemInfo])
- {
- if ($PSVersionTable.PSVersion -ge [version]'6.0') {
- $InputBytes = Get-Content $InputObject.FullName -Raw -AsByteStream
- }
- else {
- $InputBytes = Get-Content $InputObject.FullName -Raw -Encoding Byte
- }
- }
- else
- {
- ## Non-Terminating Error
- $Exception = New-Object ArgumentException -ArgumentList ('Cannot convert input of type {0} to Hex string.' -f $InputObject.GetType())
- Write-Error -Exception $Exception -Category ([System.Management.Automation.ErrorCategory]::ParserError) -CategoryActivity $MyInvocation.MyCommand -ErrorId 'ConvertHexFailureTypeNotSupported' -TargetObject $InputObject
- }
- if ($null -ne $InputBytes -and $InputBytes.Count -gt 0) {
- Write-Output (Transform $InputBytes)
- }
- }
- }
- }
- end {
- ## Output captured byte stream from piped input.
- if ($listBytes.Count -gt 0) {
- Write-Output (Transform $listBytes.ToArray())
- }
- }
- }
- function Set-WindowStyle {
- param(
- [Parameter()]
- [ValidateSet('FORCEMINIMIZE', 'HIDE', 'MAXIMIZE', 'MINIMIZE', 'RESTORE',
- 'SHOW', 'SHOWDEFAULT', 'SHOWMAXIMIZED', 'SHOWMINIMIZED',
- 'SHOWMINNOACTIVE', 'SHOWNA', 'SHOWNOACTIVATE', 'SHOWNORMAL')]
- $Style = 'SHOW',
- [Parameter()]
- $MainWindowHandle = (Get-Process -Id $pid).MainWindowHandle
- )
- $WindowStates = @{
- FORCEMINIMIZE = 11; HIDE = 0
- MAXIMIZE = 3; MINIMIZE = 6
- RESTORE = 9; SHOW = 5
- SHOWDEFAULT = 10; SHOWMAXIMIZED = 3
- SHOWMINIMIZED = 2; SHOWMINNOACTIVE = 7
- SHOWNA = 8; SHOWNOACTIVATE = 4
- SHOWNORMAL = 1
- }
- Write-Verbose ("Set Window Style {1} on handle {0}" -f $MainWindowHandle, $($WindowStates[$style]))
- $Win32ShowWindowAsync = Add-Type –memberDefinition @”
- [DllImport("user32.dll")]
- public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
- “@ -name “Win32ShowWindowAsync” -namespace Win32Functions –passThru
- $Win32ShowWindowAsync::ShowWindowAsync($MainWindowHandle, $WindowStates[$Style]) | Out-Null
- }
- #=====[ Load dynamic variables
- # Gather Computername
- $ComputerName = $env:COMPUTERNAME
- # Gather Username
- $LoggedOnUser = (qwinsta /SERVER:$ComputerName) -replace '\s{2,22}', ',' | ConvertFrom-Csv | Where-Object {$_ -like "*Acti*"} | Select-Object -ExpandProperty USERNAME
- if (!($LoggedOnUser) ) { Write-Host "No user is logged on to $ComputerName" -ForegroundColor Red ; break }
- # Gather the Team Members Full Name, instead of First.Last this will read as 'First Last'
- $dom = $env:userdomain
- $usr = $env:username
- $Fullname = ([adsi]"WinNT://$dom/$usr,user").fullname
- # Logged in team members document path
- $LoggedPath = "C:\Users\$LoggedOnUser\Documents"
- $OnePath = (Get-ChildItem $LoggedPath -recurse | Where-Object {$_.PSIsContainer -eq $true -and $_.Name -match "OneDrive"}).FullName
- $ODPathTest = $1DPath -eq "" -or $1DPath -eq $null
- if($ODPathTest -eq $False){ $1DPath = $LoggedPath + "\" + $OnePath }
- if($ODPathTest -eq $True){ $1DPath = (Get-ChildItem "C:\Users\$LoggedOnUser" -recurse | Where-Object {$_.PSIsContainer -eq $true -and $_.Name -match "OneDrive - "}).FullName }
- $1DSoftPath = $1DPath + "\Software"
- #=====[ Load Scriptblocks
- # Attribution Update
- $atrUdate = { $Cloud_Force_Software = $1DSoftPath
- get-childitem "$Cloud_Force_Software" -Depth 99 -Force -File -Recurse | where Attributes -eq 'Archive, ReparsePoint' | foreach {
- attrib.exe $_.fullname +U -P /s
- }
- Start-Sleep -second 7
- }
- # OneDrive Service
- ## Get the dynamic service name that we need to check, store as variable.
- $OD_DSync = (Get-Service -Name "OneSyncSvc*" -Exclude "OneSyncSvc").Name
- ## Check the status if the dynamically created service, store as variable.
- $OneDriveService = (get-service $OD_DSync | select Status,Can*).Status
- ## Check with boolean logic to see if the service is running, if it isn't running then we will start the service.
- $ODS_Check = $OneDriveService -eq "Stopped"
- if($ODS_Check -eq $True){ Write-Host("OneDrive is $OneDriveService... Starting Service...") ; Start-Service -Name $OD_DSync }
- if($ODS_Check -eq $False){ $null }
- #=====[ Root directory creation
- # Create Software directory
- if (Test-Path -Path $1DSoftPath) {
- # Path exists, not action needs to be taken
- } else {
- # Path does not exist, therefore create
- New-Item -Path $1DPath -Name "Software" -ItemType "directory" -EA SilentlyContinue ; sleep 5
- }
- #=====[ Software list
- # Default Applications of what comes pre-installed beforehand as part of the image.
- $STNApp_Array= @(
- # Applications from the base
- "Configuration Manager Client"
- "MDOP MBAM"
- "Microsoft InfoPath 2013"
- "Microsoft InfoPath MUI (English) 2013"
- "Microsoft Intune Management Extension"
- "Microsoft Office 32-bit Components 2013"
- "Microsoft Office OSM MUI (English) 2013"
- "Microsoft Office Proofing (English) 2013"
- "Microsoft Office Proofing Tools 2013 - English"
- "Microsoft Office Proofing Tools 2013 - Español"
- "Microsoft Office Shared 32-bit MUI (English) 2013"
- "Microsoft Office Shared MUI (English) 2013"
- "Microsoft Office Shared Setup Metadata MUI (English) 2013"
- "Microsoft Policy Platform"
- "Microsoft Update Health Tools"
- "Microsoft Visual C++ 2022 X64 Additional Runtime - 14.30.30708"
- "Microsoft Visual C++ 2022 X64 Minimum Runtime - 14.30.30708"
- "Microsoft Visual C++ 2022 X86 Additional Runtime - 14.30.30708"
- "Microsoft Visual C++ 2022 X86 Minimum Runtime - 14.30.30708"
- "Office 16 Click-to-Run Extensibility Component"
- "Office 16 Click-to-Run Licensing Component"
- "Outils de vérification linguistique 2013 de Microsoft Office - Français"
- "Teams Machine-Wide Installer"
- # Drivers
- "DisplayLink Graphics"
- "Maxx Audio Installer (x64)"
- "Realtek Audio coM Components"
- "Riverbed SteelHead Mobile"
- # Task Sequence Software Steps
- "1E Client x64"
- "7-Zip 19.00 (x64 edition)"
- "Adobe Acrobat Reader DC"
- "Cisco AnyConnect Secure Mobility Client"
- "Cisco Webex Meetings Desktop App"
- "Anyconnect Profiles 3.6"
- "Google Chrome"
- "Local Administrator Password Solution "
- "ManageEngine Desktop Central - Agent"
- "Microsoft Visio Viewer 2016"
- "UserNotificationConfig"
- "Windows Firewall Configuration Provider"
- "Zscaler"
- )
- # Gather installed software on the team members machine
- $INTApp_Array = (get-wmiobject Win32_Product | Sort-Object -Property InstallDate).Name
- # Subtract these lists and this gives us what is specificly installed on this machine.
- $App_Array = $INTApp_Array |Where-Object { $STNApp_Array -notcontains $_ }
- # Store this software list in OneDrive
- $1DSoftPath_Installed = $1DSoftPath + "\InstalledSoftware.txt"
- echo $App_Array >> $1DSoftPath_Installed
- Invoke-Command -ScriptBlock $atrUdate
- #=====[ Outlook encryption certification
- # Search the certificate store for the team members name and gather its thumbprint
- $certThumb = (dir cert: -Recurse | Where-Object { $_.Subject -like "*$Fullname*" } | select-object -first 1).Thumbprint
- ## Commented out next is this same command; but does not look at the first instance, it only looks at unique instances. Might be a good replacement.
- # $certThumb = (dir cert: -Recurse | Where-Object { $_.Subject -like "*$Fullname*" } | Select-object Thumbprint -unique).Thumbprint
- # Using this thumbprint we gather the parent paths for both certs that we need to pull for the team member.
- ## * Unsure as code generation if gather both is required as they both use the same thumbprint.
- $CertUserDS = (dir cert: -Recurse | Where-Object { $_.Thumbprint -like "*$certThumb*" } | select-object -first 1).PSParentPath
- $CertMy = (dir cert: -Recurse | Where-Object { $_.Thumbprint -like "*$certThumb*" } | select-object -last 1).PSParentPath
- # Using the janked method of encryption, set dynamic team memember specific variable
- # First.Last is store as a variable
- $CryptCode = $env:username
- # Store the first.last variable as an array
- $strArray = $CryptCode.ToCharArray()
- # Gather only odd variables from the array
- $strOdd = New-Object System.Collections.ArrayList
- $f=0; $strArray | % { if($f = !$f) { $strOdd.Add("$_") > $null } }
- # Gather only even variables from the array
- $strEvn = New-Object System.Collections.ArrayList
- $f=1; $strArray | % { if($f = !$f) { $strEvn.Add("$_") > $null } }
- # Split Odd variables from name array to its own array
- $strOdd = $strOdd -replace '(^\s+|\s+$)','' -replace '\s+',' '
- $strOdd = [string]::join("",($strOdd.Split("`n")))
- # Split even variables from name array to its own array
- $strEvn = $strEvn -replace '(^\s+|\s+$)','' -replace '\s+',' '
- $strEvn = [string]::join("",($strEvn.Split("`n")))
- # Combine Odd and Even variables together to set the first stage of this cipher
- $e_ehx = $strOdd + $strEvn
- # Setting the second stage of this cipher, convert the first stage into a hexadecimal.
- $hexconv = ConvertTo-HexString $e_ehx
- # Set the final stage of this cipher from hexadecimal to a secure string
- ## Each character in an individuals name will increase the length by 16 characters.
- ## Example. There are 436 characters for a 13 character name
- ## Example. There are 468 characters for a 15 character name
- $pfxEncrypt_Key = $hexconv | ConvertTo-SecureString -AsPlainText -Force
- # Certificate - cert:\currentuser\my
- $SaveState = $1DSoftPath + "\" + $env:username + "_PKI.pfx"
- Get-ChildItem -Path $CertMy | Export-PfxCertificate -FilePath $SaveState -Password $pfxEncrypt_Key
- # IF the pki does not backup for WHATEVER REASON -- This checks and if it does not exist then it uses another method to create the PKI PFX
- $pki_bCheck = [bool](Test-Path -Path $SaveState)
- if($pki_bCheck -eq $False){ certutil -user -p $pfxEncrypt_Key -exportpfx $certThumb $SaveState > $null }
- Start-Sleep -s 7
- $pki_bCheck = [bool](Test-Path -Path $SaveState)
- if($pki_bCheck -eq $False){ $SaveState = $1DSoftPath + "\IMPORT_PKI_FAILED.log" ; New-Item $SaveState}
- Start-Sleep -s 7
- Invoke-Command -ScriptBlock $atrUdate
- #=====[ Userprofile data backup and directory attribution update
- $1DLibCard = $1DSoftPath + "\Libraries"
- $1DLibCardOne = $1DLibCard + "\"
- New-Item -Path $1DSoftPath -Name "Libraries" -ItemType "directory" -EA SilentlyContinue
- $Library_Array= @(
- # Profile Library Copy and Attribution
- "Desktop"
- "Downloads"
- "Documents"
- "Favorites"
- "Pictures"
- "Music"
- "Temp"
- # "Videos"
- # ""
- )
- foreach ($Library in $Library_Array) {
- # A simple boolean swtich that we will use to determine the temp directory, and set a constant variable for both
- $LibraryBoolean = [bool]($Library -like "temp")
- if($LibraryBoolean -eq $false){ $locLib = $Env:USERPROFILE + "\" + $Library + "\" }
- if($LibraryBoolean -eq $true){ $locLib = "C:\temp\" }
- # Test directory to see if it exists, if it does then move contents there.
- $1DTestPath = $1DPath + "\" + $Library
- if (Test-Path -Path $1DTestPath) {
- # Path exist, so set this variable as the variable to move files into
- $1DLib = $1DTestPath
- } else {
- # Path doesn't exist.
- # A constant variable that will change with the library
- $1DLib = $1DLibCardOne + $Library
- # Create a new directory based on the library name
- New-Item -Path $1DLibCard -Name $Library -ItemType "directory" -EA SilentlyContinue
- }
- # For certain folders we need to check if they are already being synced
- $divBoolean = [bool](($Library -like "Desktop") -or ($Library -like "Pictures") )
- if($divBoolean -eq $false){ <# Nothing needs to be done here, continue like normal. #> }
- if($divBoolean -eq $true){
- $dupeDPath = $1DPath + "\" + $Library + "\"
- $TP_DP = Test-Path -Path $dupeDPath ; $TP_lL = Test-Path -Path $locLib
- # OneDrive Divergent Multiple Duplicate Library Scriptblock
- $Divergent = {
- # Gather a cohesive list of all files under the OneDrive Library Path
- $GCI_DDP = Get-ChildItem -Recurse -path $dupeDPath
- # Gather a cohesive list of all files under the User Profile Lirbary Path
- $GCI_LLP = Get-ChildItem -Recurse -path $locLib
- # Reduce the length of these variables by one to exclude the last "\""
- $dupeDPath = $dupeDPath.Substring(0,$dupeDPath.Length-1)
- $locLib = $locLib.Substring(0,$locLib.Length-1)
- # Compare directories if the files are different in local OneDrive rather than library, copy to the opposite
- Compare-Object $GCI_DDP $GCI_LLP -Property Name, Length | Where-Object {$_.SideIndicator -eq "<="} | ForEach-Object { Copy-Item "$dupeDPath\$($_.name)" -Destination "$locLib" -Force }
- # Compare directories if the files are different in local library rather than OneDrive, copy to the opposite
- Compare-Object $GCI_DDP $GCI_LLP -Property Name, Length | Where-Object {$_.SideIndicator -eq "=>"} | ForEach-Object { Copy-Item "$locLib\$($_.name)" -Destination "$dupeDPath" -Force }
- # Compare directories if the files are the same, copy to and from to ensure that the latest of each file is kept.
- Compare-Object $GCI_DDP $GCI_LLP -IncludeEqual -Property Name, Length | Where-Object {$_.SideIndicator -eq "=="} | ForEach-Object { Copy-Item "$dupeDPath\$($_.name)" -Destination "$locLib" -Force }
- Compare-Object $GCI_DDP $GCI_LLP -IncludeEqual -Property Name, Length | Where-Object {$_.SideIndicator -eq "=="} | ForEach-Object { Copy-Item "$locLib\$($_.name)" -Destination "$dupeDPath" -Force }
- # Adjust attributes to ensure that these files do not download again on the existing machine
- get-childitem "$dupeDPath" -Depth 99 -Force -File -Recurse | where Attributes -ne '' | foreach {
- attrib.exe $_.fullname +U -P /s
- }
- # Adjust attributes to ensure that these files do not download again on the existing machine
- get-childitem "$dupeDPath" -Depth 99 -Force -File -Recurse | where Attributes -eq 'Archive' | foreach {
- attrib.exe $_.fullname +U -P /s
- }
- # Adjust attributes to ensure that these files do not download again on the existing machine
- get-childitem "$dupeDPath" -Depth 99 -Force -File -Recurse | where Attributes -eq 'Archive, ReparsePoint' | foreach {
- attrib.exe $_.fullname +U -P /s
- }
- }
- # Only if there exists a folder of each possible duplicate libraries, then run the script block to copy all content to the local library,
- # so during the next stage in the process we can ensure that all files are duplicated properly.
- if(($TP_DP -eq $True) -and ($TP_lL -eq $True)){ Invoke-Command -ScriptBlock $Divergent }
- # Reset the constant variable to ensure that the script can runs as previously designed
- $locLib = $locLib + "\"
- }
- # Move contents of all files to OneDrive
- Get-ChildItem $locLib | Where-Object{$_.FullName -notlike "*OneDrive*"} | Copy-Item -Destination $1DLib -Recurse -Force
- Start-Sleep -Seconds 15
- # Adjust attributes to ensure that these files do not download again on the existing machine
- get-childitem "$1DLib" -Depth 99 -Force -File -Recurse | where Attributes -eq 'Archive' | foreach {
- attrib.exe $_.fullname +U -P /s
- }
- # Adjust attributes to ensure that these files do not download again on the existing machine
- get-childitem "$1DLib" -Depth 99 -Force -File -Recurse | where Attributes -eq 'Archive, ReparsePoint' | foreach {
- attrib.exe $_.fullname +U -P /s
- }
- }
- #=====[ Application specific task array
- #===========[ Chrome - Bookmarks data
- #===========[ Network Drives - Drive information and UNC Path
- #===========[ Printers - Friendly Names, UNC Path, and driver information
- #===========[ Stickey Notes - Database backup
- $root_Array= @(
- # Software Library Copy and Attribution
- "Chrome"
- "Drives"
- "Printers"
- "Sticky Notes"
- # "Edge"
- # ""
- )
- foreach ($root in $root_Array) {
- # Variable software array based directory creation
- $1D_softPath = $1DSoftPath + "\" + $root
- New-Item -Path $1DSoftPath -Name $root -ItemType "directory" -EA SilentlyContinue
- ## Script Blocks containing each set of commands appropriate to the task based on the software array
- $sb_Chrome = { ## Backup Chrome bookmarks
- Copy-Item -Path "$env:userprofile\appdata\local\google\chrome\User Data\default\bookmarks" $1D_softPath
- }
- $sb_Drives = {# Gather all drives and store the Drive letter, the network location, and the friendly name of every network drive.
- $DriveArray = Get-WmiObject -ClassName Win32_MappedLogicalDisk | Select Name, ProviderName, VolumeName
- # For each item in this drive array..
- Foreach ($Drive in $DriveArray) {
- # Get each drive letter
- $DriveLetter = ($Drive).Name
- # Get each drive path
- $DrivePath = ($Drive).ProviderName
- # Get each drive volume name
- $DriveVolume = ($Drive).VolumeName
- # Trim the colon from the drive letter
- $DriveLetter = $DriveLetter.Substring(0,$DriveLetter.Length-1)
- # Set variables for dynamic creation
- $SavedDrive = $DriveLetter + ".log"
- $1D_NetDrive = $1D_softPath + "\" + $SavedDrive
- # If the drive file exists then we must remove the file to not taint drive information
- if (Test-Path $1D_NetDrive) { Remove-Item $1D_NetDrive }
- # Create drive log file and store drive letter as file name
- New-Item -Path $1D_softPath -Name $SavedDrive
- # Store friendly name of drive as first line
- Add-Content -Path $1D_NetDrive -Value "$DriveVolume" -Force
- # Store UNC path of drive as second line
- Add-Content -Path $1D_NetDrive -Value "$DrivePath" -Force
- }
- }
- $sb_Printers = { # Default Printers of what comes pre-installed beforehand as part of the image.
- $stnPrint_Array= @(
- # Default Printer array
- "Local Administrator Password Solution"
- "Webex Document Loader"
- "OneNote (Desktop)"
- "Microsoft XPS Document Writer"
- "Microsoft Print to PDF"
- "Fax"
- )
- # Gather printers team members machine
- $INTPrint_Array = (Get-Printer).Name
- # Subtract these lists and this gives us what printers are on this machine.
- $Print_Array = $INTPrint_Array |Where-Object { $stnPrint_Array -notcontains $_ }
- ForEach ($printer in $Print_Array) {
- $pnt_fName = (Get-Printer -Name $printer).ShareName
- $pnt_uName = (Get-Printer -Name $printer).Name
- $pnt_pName = (Get-Printer -Name $printer).PortName
- $pnt_dName = (Get-Printer -Name $printer).DriverName
- $pnt_Location = (Get-Printer -Name $printer).Location
- $pnt_Comment = (Get-Printer -Name $printer).Comment
- $SavedPrinter = $pnt_fName + ".log"
- $1D_Printer = $1D_softPath + "\" + $SavedPrinter
- # Create drive log file and store drive letter as file name
- New-Item -Path $1D_softPath -Name $SavedPrinter
- # Store UNC path of printer as first line
- Add-Content -Path $1D_Printer -Value "$pnt_uName" -Force
- # Store port of printer as second line
- Add-Content -Path $1D_Printer -Value "$pnt_pName" -Force
- # Store driver name of printer as third line
- Add-Content -Path $1D_Printer -Value "$pnt_dName" -Force
- # Store location of printer as fourth line
- Add-Content -Path $1D_Printer -Value "$pnt_Location" -Force
- # Store comment of printer as fifth line
- Add-Content -Path $1D_Printer -Value "$pnt_Comment" -Force
- # Add-Content -Path $1D_Printer -Value "" -Force
- }
- }
- $sb_StickNote = { # Location of the existing stickynote archive.
- $stn_sql = $Env:LocalAppData + "\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\plum.sqlite"
- # Stop Sticky Notes process on the current machine
- Get-Process | Where-Object {$_.MainWindowTitle -like "*Sticky Notes*"}| Stop-Process
- # Copy Sticky Notes backup file
- Copy-Item -Path $stn_sql -Destination $1D_softPath
- }
- $sb_Edge = {
- # If Edge is running then stop this process.
- Stop-Process -Name "MsEdge" 2>$null
- $Edge_Stop = Get-Process -Name "MsEdge" 2>$null
- Stop-Process -InputObject $Edge_Stop 2>$null
- Get-Process | Where-Object {$_.HasExited}
- # Create backup of Edge Preferences
- Backup-EdgeProfile -Channel 'Stable' -ExportPath $1D_softPath
- Start-Sleep -s 3
- # Start Edge after the backup.
- Start-Process microsoft-edge:
- sleep 3
- $wshell = New-Object -ComObject wscript.shell;
- $wshell.AppActivate('New tab - Work - Microsoft Edge')
- Sleep 2
- $wshell.SendKeys("^+{T}")
- sleep 3
- (Get-Process | Where-Object {$_.MainWindowTitle -like "*Edge*"}).MainWindowHandle | foreach { Set-WindowStyle MINIMIZE $_ }
- sleep 2
- $wshell = New-Object -ComObject wscript.shell;
- $wshell.AppActivate('New tab - Work - Microsoft Edge')
- Sleep 2
- $wshell.SendKeys("^{W}")
- sleep 3
- (Get-Process | Where-Object {$_.MainWindowTitle -like "*Edge*"}).MainWindowHandle | foreach { Set-WindowStyle MAXIMIZE $_ }
- }
- # If site equals a specific site then use a specific tool
- switch ($root) {
- "Chrome" { Invoke-Command -ScriptBlock $sb_Chrome ; break}
- "Drives" { Invoke-Command -ScriptBlock $sb_Drives ; break}
- "Printers" { Invoke-Command -ScriptBlock $sb_Printers ; break}
- "StickNote" { Invoke-Command -ScriptBlock $sb_StickNote ; break}
- "Edge" { Invoke-Command -ScriptBlock $sb_Edge ; break}
- # "banana" { "We found a banana"; break} # template
- default { "Default" ; break}
- }
- Start-Sleep -Seconds 7
- # Adjust Permissions to ensure that these files do not download again on the team members machine
- get-childitem "$1D_softPath" -Depth 99 -Force -File -Recurse | where Attributes -eq 'Archive, ReparsePoint' | foreach {
- attrib.exe $_.fullname +U -P /s
- }
- }
- #=====[ Attribution alterations command set
- # Adjust Permissions to ensure that these files do not download again on the team members machine
- $Cloud_Force_Software = $1DSoftPath
- get-childitem "$Cloud_Force_Software" -Depth 99 -Force -File -Recurse | where Attributes -eq 'Archive, ReparsePoint' | foreach {
- attrib.exe $_.fullname +U -P /s
- }
- $attr_Message = "Altering " + "'" + $Cloud_Force_Software + "'" + " folder attributes....."
- Write-Host($attr_Message)
- Start-Sleep -seconds 7
- # Adjust Permissions to ensure that these files do not download again on the team members machine
- $Cloud_Force_Libraries = $1DLibCard
- get-childitem "$Cloud_Force_Libraries" -Depth 99 -Force -File -Recurse | where Attributes -eq 'Archive, ReparsePoint' | foreach {
- attrib.exe $_.fullname +U -P /s
- }
- #=====[ Final directory attribution set
- # Adjust Permissions to ensure that these files do not download again on the team members machine
- $Cloud_Force_Libraries = $1DSoftPath
- get-childitem "$Cloud_Force_Libraries" -Depth 99 -Force -File -Recurse | where Attributes -eq 'Archive, ReparsePoint' | foreach {
- attrib.exe $_.fullname +U -P /s
- }
Add Comment
Please, Sign In to add comment