From 52bae2193342ed33381c7f59ee9507de24e422c9 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Thu, 24 May 2018 15:33:36 -0700 Subject: [PATCH] Remove unused PowerShell scripts --- .../hyperv/scripts/utils/create_session.ps1 | 34 ----------- .../smb/scripts/mount_share.ps1 | 56 ------------------- .../synced_folders/smb/scripts/ps_version.ps1 | 1 - 3 files changed, 91 deletions(-) delete mode 100644 plugins/providers/hyperv/scripts/utils/create_session.ps1 delete mode 100644 plugins/synced_folders/smb/scripts/mount_share.ps1 delete mode 100644 plugins/synced_folders/smb/scripts/ps_version.ps1 diff --git a/plugins/providers/hyperv/scripts/utils/create_session.ps1 b/plugins/providers/hyperv/scripts/utils/create_session.ps1 deleted file mode 100644 index fcf0f7f10..000000000 --- a/plugins/providers/hyperv/scripts/utils/create_session.ps1 +++ /dev/null @@ -1,34 +0,0 @@ -#------------------------------------------------------------------------- -# Copyright (c) Microsoft Open Technologies, Inc. -# All Rights Reserved. Licensed under the MIT License. -#-------------------------------------------------------------------------- - -function Get-Remote-Session($guest_ip, $username, $password) { - $secstr = convertto-securestring -AsPlainText -Force -String $password - $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr - New-PSSession -ComputerName $guest_ip -Credential $cred -ErrorAction "stop" -} - -function Create-Remote-Session($guest_ip, $username, $password) { - $count = 0 - $session_error = "" - $session = "" - do { - $count++ - try { - $session = Get-Remote-Session $guest_ip $username $password - $session_error = "" - } - catch { - Start-Sleep -s 1 - $session_error = $_ - $session = "" - } - } - while (!$session -and $count -lt 20) - - return @{ - session = $session - error = $session_error - } -} diff --git a/plugins/synced_folders/smb/scripts/mount_share.ps1 b/plugins/synced_folders/smb/scripts/mount_share.ps1 deleted file mode 100644 index fa1f98133..000000000 --- a/plugins/synced_folders/smb/scripts/mount_share.ps1 +++ /dev/null @@ -1,56 +0,0 @@ -param ( - [string]$share_name = $(throw "-share_name is required."), - [string]$guest_path = $(throw "-guest_path is required."), - [string]$guest_ip = $(throw "-guest_ip is required."), - [string]$username = $(throw "-username is required."), - [string]$password = $(throw "-password is required."), - [string]$host_ip = $(throw "-host_ip is required."), - [string]$host_share_username = $(throw "-host_share_username is required."), - [string]$host_share_password = $(throw "-host_share_password is required.") - ) - -# Include the following modules -$presentDir = Split-Path -parent $PSCommandPath -$modules = @() -$modules += $presentDir + "\utils\create_session.ps1" -$modules += $presentDir + "\utils\write_messages.ps1" - -forEach ($module in $modules) { . $module } - -try { - function Mount-File($share_name, $guest_path, $host_path, $host_share_username, $host_share_password) { - try { - # TODO: Check for folder exist. - # Use net use and prompt for password - $guest_path = $guest_path.replace("/", "\") - # Map a network drive to the guest machine - $result = net use * $host_path /user:$host_share_username $host_share_password /persistent:yes - $mapped_drive = (($result -match "\w:") -split (" "))[1] - Write-Host cmd /c mklink /d $guest_path $mapped_drive - # If a folder exist remove it. - if (Test-Path $guest_path) { - $junction = Get-Item $guest_path - $junction.Delete() - } - cmd /c mklink /d $guest_path $mapped_drive - } catch { - return $_ - } - } - - $response = Create-Remote-Session $guest_ip $username $password - - if (!$response["session"] -and $response["error"]) { - Write-Error-Message $response["error"] - return - } - $host_path = "\\$host_ip\$share_name" - $host_share_username = "$host_ip\$host_share_username" - $result = Invoke-Command -Session $response["session"] -ScriptBlock ${function:Mount-File} -ArgumentList $share_name, $guest_path, $host_path, $host_share_username, $host_share_password -ErrorAction "stop" - Remove-PSSession -Id $response["session"].Id - Write-Error-Message $result -} -catch { - Write-Error-Message "Failed to mount files VM $_" - return -} diff --git a/plugins/synced_folders/smb/scripts/ps_version.ps1 b/plugins/synced_folders/smb/scripts/ps_version.ps1 deleted file mode 100644 index 89fbab28e..000000000 --- a/plugins/synced_folders/smb/scripts/ps_version.ps1 +++ /dev/null @@ -1 +0,0 @@ -Write-Output $PSVersionTable.PSVersion.Major