I have a script (approx. 1200 lines), where the last peace (inheritance), doesn’t work as expected. The script consists of (Head office, Company1, Company2, Company3, Company4), where different programming techniques has been used. Last comment, AI has produced the code over a long period of time; but can’t get hold of this last peace. Can I get help here. I know it’s a lot of code sending over the net, so what do you say??
how long is the piece that doesn’t work? Can you share that?
For starters, I can show you my Test snippet, that should give a good indication of what’s going on. I think you should have a look fist and we can take from there, OK?
I just tried to upload my .ps1 Powershell file; but that’s no go?
Yeah pretty sure you can’t upload files to the forum. Seems like a massive security risk.
You can use the “preformatted text” button to share code directly within your reply:
Or maybe you can throw it in Pastebin or github?
I’ll give it a go,let us see how you receive it and I can an introduction afterwards OK
# Headquarters.ps1
# Load the VITAL 3
. .\CompanyBase.ps1
. .\CompanyCustomerSupport.ps1
# Load the Company1 class
. .\Company1.ps1
# Load the Company2 class
. .\Company2.ps1
# Load the Company3 class
. .\Company3.ps1
# Load the Company4 class
. .\Company4.ps1
# Create instances of companies
$company1 = [Company1]::new("Alpha Corp", "123 Business Rd", "555-1234")
$company2 = [Company2]::new("Beta Corp", "456 Industry Ln", "555-5678")
$company3 = [Company3]::new("Gamma Inc.", "789 Corporate Blvd", "555-8765", "John Doe")
$company4 = [Company4]::new("Delta LLC", "456 Industrial Ave", "555-4321")
# Invoke specific operations
$company1.SpecificOperation()
$company2.SpecificOperation()
$company3.SpecificOperation()
$company4.SpecificOperation()
The inheritance trick in the script, is to have a GENERIC text when CompanyBase overrides call to SpecificOperation. The method is left out in one of the Companies to reveal the correct inheritance. I have tested with a bunch of different solutions; but Unfortunately without success. OK
Ok well, maybe it’s just me, but I have no idea what’s going on or what “inheritance” means in this context so I’m gonna bow out for now.
Where does that leave me? I was just about to get the script on GITHUB for you to do “full tests” on !?!
Since you’re working with classes, what’s - in my experience - not that common for common PowerShell scripters you may be better of in a forum where you can find some C# developers as well. StackOverflow is a well known place .
But I’d recommend to prepare a minimal reproducable example before you ask your question there. I think it would be asked too much if you expect someone to review your 1,200 lines of code.
![]()
You could do that anyway. ![]()
BTW: Did you read the available help topic about classes and inheritance in PowerShell?
Maybe you could back up a step and actually explain what your problem is, and what you are trying to accomplish. Your code doesn’t really help at all, and stating ‘it doesn’t work’ isn’t helpful. You’re dot sourcing some files then assigning vars by using some classes, then calling a method called specificoperation which we have no idea what it does. We have no clue what ‘inheritance’ means in this context. You’re making huge assumptions of your audience then basically saying ‘fix it’. That’s not what we do here. We don’t run ‘full tests’ on your code. You come to us with a well written problem, provide context, error messages, intent, etc. and we can try to assist :). No offense it comes off as you just throwing code to the Internet, and asking for folks to ‘fix it’ without any knowledge of what’s going on.