Import .xml file into project and use it

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
michael.heinrich
Posts: 8
Last visit: Tue Mar 12, 2024 6:05 am

Import .xml file into project and use it

Post by michael.heinrich »

Hello together,

i want to make a Powershell Script (GUI) which imports our Wifi Profile and check if already exist.
is there a possibility to import the profile .xml into the project and import it with netsh from the project source? I dont want to import from a network share because of different company locations etc.

I already tried to Add an existing file into the project. It is shown in the explorer but i dont know how to use it to import with netsh.

Thank you!

Kind regards

Michael
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Import .xml file into project and use it

Post by jvierra »

What do you mean by "import"? You can easily display the output of NETSH commands in a textbox. Is this what you are asking?
Bosparan
Posts: 290
Last visit: Fri Oct 08, 2021 11:59 am

Re: Import .xml file into project and use it

Post by Bosparan »

Hi Michael,

you can copy the profile-text into your project files as a multi-lined string:

Code: Select all

$profile = @'
<this>
  <line>
    <has>
      <Totally multiple="lines" />
      <replace with="profile-text" />
    </has>
  </line>
</this>
'@
Then use set-content to write it to a temporary file locally, then run netsh against the local file.

Cheers,
Fred
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Import .xml file into project and use it

Post by jvierra »

Issue - profiles are exported to XML file on supplied or current path.

Too import a file use Get-Content

[xml]$profile = Get-Content <<path>\profile name>.XML

To apply with netsh use the netsh import command with the file name.

The purpose for the original question is still too vague.
This topic is 6 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked