0

I'm looking to make a super simple request for input script that uses said input to be executed in the script below. I can edit the script before I run it each time, but it would be way cooler and more practical if you could just enter the PCname and User ID. Basically, :request for inputA, enter, request for InputB, enter. Take both inputs(A and B) and put them in the script then run it.

I'm sure this is simple, but I'm just getting started with this adventure.

Something like this :-

Copy-Item -LiteralPath \\(PCname)\C$\Users\(UserID)\AppData\Roaming\Nuance\NaturallySpeaking12\Dragon.log
-Destination "\\Static PC\C$\Users\MyName\Desktop\Dragon Logs" -Force
pnuts
  • 58,317
  • 11
  • 87
  • 139
  • 1
    Are you asking us to make a function with your sample? You should be able to do that easily with help from [about_functions](https://technet.microsoft.com/en-us/library/hh847829.aspx) – Matt Jun 12 '15 at 23:13
  • possible duplicate of [Need help on Powershell Copy-Item from network drives](http://stackoverflow.com/questions/14653851/need-help-on-powershell-copy-item-from-network-drives) – Mathias R. Jessen Jun 13 '15 at 00:30
  • Your question has been put on hold as unclear. I'm going to try to clarify for you what may be making your question less clear to the experts. There are three hints in your question about where you are coming from. First, you tell us youre' just getting started. Second you use (PCname) in your example, where a Powershell user would use $PCname. Third, you make use of the -LiteralPath parameter, which is not very widely used, and was included only to deal with a very specific case, and one that only arises within windows when some unfortunate naming choices have been made. – Walter Mitty Jun 13 '15 at 12:49

1 Answers1

2

Try this:

$PCname = Read-Host "Please enter the PC Name"
$Userid = Read-Host "Please enter the Uder ID"

Copy-Item -LiteralPath \\$PCname\C`$\Users\$UserID\AppData\Roaming\Nuance\NaturallySpeaking12\Dragon.log -Destination "\\Static PC\C`$\Users\MyName\Desktop\Dragon Logs" -Force

$PCname and $Userid are examples of powershell variables. The values are to be entered when you run the script. The other answer is trying to show you how to pick up the name of a computer on the network automatically, but that isn't what you asked for.

I put a backtick in front of the two dollar signs you have in your sample so as to prevent them from being seen as introducing a variable. This is probably unnecessary, but I put them in just in case.

Walter Mitty
  • 18,205
  • 2
  • 28
  • 58
  • Worked like a charm!! Asks for PC name and User name then completes the log dump. – ChunkALunkk Jun 15 '15 at 13:14
  • If you would like to accept the answer as correct, you can do so by clicking the check mark next to the answer. Only the person who asked the Q can accept the answer, although anyone can upvote it. – Walter Mitty Jun 15 '15 at 14:21
  • So I found this to be a great solution, however being all the files are named the same in my storage folder, I added the user and pc and renamed the file. Code below : – ChunkALunkk Jun 15 '15 at 15:02
  • $PCname = Read-Host "Please enter the PC Name" $Userid = Read-Host "Please enter the Uder ID"
    Copy-Item -LiteralPath \\$PCname\C`$\Users\$UserID\AppData\Roaming\Nuance\NaturallySpeaking12\Dragon.log -Destination "\\PCName\C`$\Users\[User]\Desktop\Dragon Logs" -Force pause
    Rename-Item -Path "\\PCName\C`$\Users\[User]\Desktop\Dragon Logs\Dragon.log" -NewName $PCname$Userid".log"
    – ChunkALunkk Jun 15 '15 at 15:03