function Set-Clipboard {
	param($text)

	# need to use temp file to avoid exceeding command-line length limit
	$temp = [io.path]::GetTempFileName()

	try {
		set-content -Path $temp -Value $text

		$command = {
			add-type -an system.windows.forms
			[System.Windows.Forms.Clipboard]::SetText((get-content $args))
		}

	powershell -sta -noprofile -command $command -args $temp

	} finally {
		if ((test-path $temp)) {
		remove-item $temp
		}
	}
}
 
function Get-Clipboard {
	$command = {
		add-type -an system.windows.forms
		[System.Windows.Forms.Clipboard]::GetText()
  }
	powershell -sta -noprofile -command $command
}

function Set-DirectoryViaClipboard {
	$dir = get-clipboard
	$dir = $dir.Trim("`"")
	if ([System.IO.Directory]::Exists($dir)) { cd $dir }
	else  {
		$dir = [System.IO.Path]::GetDirectoryName($dir)
		if ([System.IO.Directory]::Exists($dir)) { cd $dir }
	}
}

set-alias ccd Set-DirectoryViaClipboard