MacOS: Printer? / Executables? / Multiple hard-drive roots?

Welcome Forums General PowerShell Q&A MacOS: Printer? / Executables? / Multiple hard-drive roots?

  • This topic has 3 replies, 2 voices, and was last updated 3 months ago by
    Moderator
    .
Viewing 3 reply threads
  • Author
    Posts
    • #205092
      Participant
      Topics: 3
      Replies: 5
      Points: 33
      Rank: Member

      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

    • #205275
      Moderator
      Topics: 3
      Replies: 216
      Points: 1,176
      Helping Hand
      Rank: Community Hero

      Hi there,

      What is your actual requirement?

      Please refer to the help links from Microsoft docs

      1. https://docs.microsoft.com/en-us/powershell/module/printmanagement/get-printer?view=win10-ps
      2. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-7
      3. 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.

    • #205692
      Participant
      Topics: 3
      Replies: 5
      Points: 33
      Rank: Member

      Hi there,

      What is your actual requirement?

      Please refer to the help links from Microsoft docs

      1. https://docs.microsoft.com/en-us/powershell/module/printmanagement/get-printer?view=win10-ps
      2. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-7
      3. 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.

      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

    • #205839
      Moderator
      Topics: 3
      Replies: 216
      Points: 1,176
      Helping Hand
      Rank: Community Hero

      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

      Get-Content -Path ./Desktop/Scripting/Processes.txt | Out-Printer -Name ‘Canon MX450’

      And the other, try this…

      $MyPC = ‘./Desktop/Scripting/Exercises PowerShell/MyPC.txt’
      $Atom = ‘./Users/Mido/Applications/Atom’
      
      Start-Process -FilePath $Atom -ArgumentList $MyPC

      Thank you.

      • This reply was modified 3 months ago by Kiran. Reason: Spelling
Viewing 3 reply threads
  • The topic ‘MacOS: Printer? / Executables? / Multiple hard-drive roots?’ is closed to new replies.