Dear all,
I have three questions that I got stuck with !
Q1) How can I use PowerShell to find my personal printer which is connected to the same WIFI as my Macbook, how to configure and how can I send a file to print?
<hr />
Q2) Opening a text file from the command-line with APP: E.g (Atom and view the content of text file? (Running Executables)
PS: Path to my text file and the app I want to use are mentioned below!
For this one I tried to assign two variables then ‘Start-Process’ but nothing happened!
| $MyPC = "./Desktop/Scripting/Exercises PowerShell/MyPC.txt"
$Atom = “./Users/Mido/Applications/Atom”
Start-Process $Atom++ $MyPC
|
<hr />
Q3) If I have two hard-drives and my main’s root is “./” what would the main root of my secondary hard-drive if i’m trying to access it from the main hard-drive?
<hr />
Any help would be appreciated 
Many thanks,
Mido
[quote quote=205275]Hi there,
What is your actual requirement?
Please refer to the help links from Microsoft docs
- https://docs.microsoft.com/en-us/powershell/module/printmanagement/get-printer?view=win10-ps
- https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-7
- https://docs.microsoft.com/en-us/powershell/module/storage/get-disk?view=win10-ps
1 and 3, you can also get the info using
Get-CimInstance with appropriate CIM classes.
Thank you.
[/quote]
Dear Kiran,
I do not have the “Get-CimInstance” module I believe it does not exist for macOS, please correct me if i’m mistaken.
I have been trying the following commands for the printer question with no luck
<hr />
Get-Content -Path ./Desktop/Scripting/Processes.txt | Out-Printer
<hr />
It gives the following error:
<hr />
Out-Printer : No printers are installed.
<p class="p1">At line:1 char:55</p>
<p class="p1">+ Get-Content -Path ./Desktop/Scripting/Processes.txt | Out-Printer</p>
<p class="p1">+ ~~~~~~~~~~~</p>
<p class="p1">+ CategoryInfo: NotSpecified: (:) [Out-Printer], InvalidPrinterException</p>
<p class="p1">+ FullyQualifiedErrorId : System.Drawing.Printing.InvalidPrinterException,OutPrinterCommand.OutPrinterCommand</p>
<hr />
Even though I scanned for printers and it says it is there => Canon MX450 :Idle
<hr />
My second question is about how to open for example a ‘.txt’ file using a different app than the default one.
Like for the moment if I use the ‘start’ or the invoke-item commands, it uses the EditText app on mac.
But let’s say I want it to run the file using ‘Atom’ instead via PowerShell no manually changing the default app.
For the 3rd question, it is solved. Thank you!
I appreciate any sort of help!
Regards,
Mido
Yes, you don’t see Get-CIMInstance on Mac for sure.
Check to see your target printer is set to default.
Add -Name parameter to Out-Printer and see
[pre]Get-Content -Path ./Desktop/Scripting/Processes.txt | Out-Printer -Name ‘Canon MX450’[/pre]
And the other, try this…
[pre]$MyPC = ‘./Desktop/Scripting/Exercises PowerShell/MyPC.txt’
$Atom = ‘./Users/Mido/Applications/Atom’
Start-Process -FilePath $Atom -ArgumentList $MyPC[/pre]
Thank you.