Coder Social home page Coder Social logo

Comments (4)

rlwakefield avatar rlwakefield commented on August 16, 2024 1

Thank you for those details. I completely understand and respect your choice. I will close out this issue as your answer makes sense and does help. 😃

from adessentials.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 16, 2024

Save-HTML comes from PSWriteHTML and its soft-way of fallback when the given path doesn't exist so that the file is not lost. Creating a path may be a dangerous way so I try not to do it and expect the user to do it themselves properly. Not sure I want to change that behavior as I am a bit afraid of the flaw in that logic and consequences for more complicated paths.

from adessentials.

rlwakefield avatar rlwakefield commented on August 16, 2024

Oh yes, I completely understand and agree that it can be a difficult thing. I guess the bigger reason I was thinking was let's say we schedule the report to run over multiple groups and to store the HTML in a folder that is named something dynamically. Well, the problem here is I now have to add it to my code to make sure that I create those dynamically named folders which means adding more code to my script/call.

So for example, here is my script.

$groupName = "[name]"
Show-WinADGroupMember -GroupName $groupName -FilePath (-Join("C:\Temp\Reports",$groupName,"GroupMembership.html"))

The method/call works GREAT, but it just has to fall back to saving the file to my "C:\Users[username]\AppData\Local\Temp[number].html" path to save the file. Maybe as an alternative (again, just a suggestion), an additional parameter could be used like "-Force" and combine it with a Test-Path method call? Of course I have to rely on your expertise and knowledge of the code and all to determine if this is really able to be used or not. If I need to put in a Pull Request for official work/review, I am more than happy to do so. :)

from adessentials.

PrzemyslawKlys avatar PrzemyslawKlys commented on August 16, 2024

What happens if the user makes a typo and it creates a path? I can't solve all problems. The Save-HTML is supposed to help if a mistake was made and the user was using cmd interactively. Surely if you're going to schedule something you can add 2-3 more lines of code?

The cmdlet can take multiple groups, so just create folder and use a single file for multiple groups?

Or add the single line above? New-Item -ItemType Directory "C:\Temp\Reports\" -Force

Also this join for sure doesn't give you C:\Temp\Reports\GroupNameGroupMembership.html
-FilePath (-Join("C:\Temp\Reports",$groupName,"GroupMembership.html"))

And if I would force it for you the C:\Temp\ReportsSomeGroupNameGroupMembership.html would be used, and just C:\Temp would be created.

I do sometimes add dir creation with force of path - but I just don't feel this is the correct place to do it.

from adessentials.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.