Closed Kvoo closed 2 years ago
I am not sure what you mean. The Status is not pushed into console. If you catch it to variable it will be an object... unless you use $Supress it always returns an object. Return is not required in PowerShell
Leaving it like that - means return an object to a user
Sorry, talking specifically about the Receive-SFTPFile function. That one doesn't return the status :)
Looks like it's just missing the if not suppress
It's missing not suppress but that also means it returns status and has no ability to suppress it. But the object is being returned
So should i be able to call it using $Status after running the function?
This doesn't return the Variable, does it? From what I gather, it just outputs it to the console.
$YourVariable = Receive-SFTPFile
$Status when used like I am using it - is scoped to the function. You can also do
$Status = Receive-SFTPFile
- but this will be a "different $Status variable
My god I'm so sorry, you're totally right. My train of thought was way too complicated, didn't think about just assigning the function to a variable. I'm still learning :) Thank you!
Heya! I'm using your Package to automate downloading SFTP Files and then sending them via E-Mail and deleting them off the external SFTP Server. When I'm done I'd like to upload it to github for others to use, with parameters, etc.
I see that in some of your functions, you create a custom Object "Status" and then print that object into the console, which is great!
Would it be possible that you return this object instead of just outputting it to the console? I'd like to run an if check on "Status = True/False" after running the func. If true, move the file to an array of downloaded files and only if it's contained in that array, delete it on the SFTP server.
And I don't want to just copy the function into my script or change your module, I'd like people to be able to use the module as-is when they use my script :) Or are you okay with me copying the function, adding a return statement and giving you credit for it in the script?