• Good day, I appreciate your assistance. However my problem is filtering column rows in a said csv file. The csv file has a header which is "Comment" and I would like to filter with multiple comments

    0
  • Hi, Checker33. Thank you for the feedback, I am glad you found this useful.

    Yes, you may include the function in a custom PowerShell Module that you can load manually or automatically in your PowerShell console, editor etc. If the previous sentence sounds intimidating, create a new file with the extension ".psm1" (like "MyCustomfunctions.psm1"). Paste the code from this post in the psm1 file, and save it. When you want to run the function, import the module (Import-Module 'C:tempMyCustomfunctions.psm1") and then the function will be available.

    You may also save as a normal PowerShell script file (PS1), and then reference it using the . (dot). Yes, the command begins with a dot followed by a space and then the path to the PS1 file.

    . "C:tempMyCustomfunctions.ps1"

    If you're interested in more details, I could write a post on how to do this (both manually or automatically).

    Cheers. Emanuel

    0
  • Hi, very helpful. But how can i wrap this , so use the function under domain administrator creds?

    0
  • $MailParams = @{
      SMTPServer  = 'mail.domain.com'
      Port        = 25
      To          = 'user@domain.com'
      From        = 'someotheruser@domain.com'
      Body        = 'Here is my attachment'
      Attachments = 'c:tempattachment1.zip','c:temptest.txt'
      Subject     = 'Testing attachment capabilities'
     }
    Send-MailMessage @MailParams
    

    That's pretty much it. The attachments just need to be an array of paths to the items.

     

    David F.

    0
  • Real nice article on filtering (in any way).
    A good way to start to understand it, with easy to follow examples.
    Using the same data and go from there really show how to handle all the different options.
    Wich more was like this (and a lot of them are, BUT just TOO hard to find). Thanks (saved the link - it will help me much)

    0
  • Hello All,

    Can someone please post the working code for sending an attachment via email using Powershell. I have tried some online code, but I am unable to do so.

    Thanks

    IQ

    0
  • Noone said there is something wrong with the module you share 🙂 The question was about native export commands which is much easier and faster than learn how to work with a specific module.

    0
  • Hehe thanks 🙂 Your welcome.

    I had the same issue few days ago when I audited few PCs... 🙂 Just did all on screen with format-table and when I was happy I just added | Export-CSV. It took me a while before I realized I forgot to remove the format thing 🙂

    Format commands are only used as last commands to display results, as they completely change the member type.

    0
  • Any idea how to force the SNMP traps sent from windows to be sent in a version other than V1? They are showing up on the destination as V1 and not V2 or V2C. I have spent a few days now with this problem. Other than that, your post has been very helpful. Thanks!

    0
  • Very good article thanks.

    Can I add that the command to  to load PoSh DHCPServer module is : 

    Add-WindowsFeature -Name DHCP –IncludeManagementTools

    0
  • What's wrong with the ImportExcel module? (It can do all sorts of Excel things.....)

    0
  • A DHCP server is a critical component of the IT infrastructure in most environments. In addition to monitoring, which ensures the basic availability of the service, you may also want to check the status of the IP scopes or leases. PowerShell provides several cmdlets for this purpose.

    0
  • Excellent help, Leos. You are a real Pro, it works like a charm. Great help. Thank you so much.

    0
  • oh and remove the -autosize parameter

    0
  • Replace Format-table with Select-object and you are all set.
    any formatting using format commands is for display only.

    0
  • How to export the output of the Get-ADUser cmdlet to an Excel file? Excel-CSV is not showing the output as expected. It's showing ASCII characters. On the other hand, if I use Out-File C:ADUsers.txt  to generate a txt file it works fine. But I need to generate a CSV or an Excel file. How can I do this?

    I am using  Export-Csv -Path  c:tempUserData.csv.

    import-module activedirectory
    Get-ADUser -Filter * -Properties * |
    sort-object -property SamAccountName |
    Format-Table -property `
    @{Name="Logon Name";Expression={$_.SamAccountName}},
    @{Name="First Name";Expression={$_.givenName}},
    @{Name="Initials";Expression={$_.Initials}},
    @{Name="Last Logon";Expression={$_.LastLogonDate}}`
    -AutoSize |
    Out-File C:ADUsers.txt
    1+
  • I'm glad to help. I enjoy doing this stuff, and I need help plenty of times myself 🙂

    I reverted to takeown because I wasn't sure how to do that with Powershell (I know it *can* be done, but the how is much more complicated than I had time to research).   It can be done with subinacl also, but that syntax is definitely more complicated.

    I think this site is a fantastic site, and we all want to help each other.  🙂

     

    And the one other thing I thought about, you could just do the takeown before you run the script and then recursively insert permissions so you can delete it if needed.

    The -f switch is a fantastic feature.  One of the problems I always had in DOS and vbscripts was dealing with quote marks.  I can't count the number of times I've had to go back and double & triple count my double quote marks to debug problems.

    The way -f works is it substitutes in information when it evaluates the string.  The placeholders represent the position in a list of variables after the -f.  Here's an example:

    'Today is a {0} day to {1}' -f 'good','die' evaluates to 'Today is a good day to die'

    'My username is {0}, and my profile directory is {1}' -f $env:username, $env:userprofile evaluates to 'My username is david and my profile directory is c:usersdavid'

    Good luck!

    David F.

     

    0
  • Load More