Skip to content

Fix set-content failure on Linux for creating file in psdrive. (#2206) - #2392

Merged
Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
charub:2206
Oct 28, 2016
Merged

Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
charub:2206

Conversation

@charub

@charub Charu Bassi (charub) commented Sep 30, 2016 •

Copy link
Copy Markdown
Contributor

Resolving #2206

Following scenario failed on Linux:
new-psdrive -name TESTDRIVE -root /home/user1/test -psprovider FileSystem
'abc' | set-content -path TESTDRIVE:/testfile.txt

Set-Content fails to create a file for PSDrive path, if the path root begins with defaultPathSeperatorString (ex: UNC path and paths in Single rooted filesystems like Unix)

@msftclas

Hi Charu Bassi (@charub), I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (Charu Bassi). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.

TTYL, MSBOT;

@vors

Copy link
Copy Markdown
Collaborator

That seems to interfere with #2325
cc Andy Jordan (@andschwa)

@charub

Copy link
Copy Markdown
Contributor Author

James Truher (@JamesWTruher) : Please have a look

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$SkipNotAdmin = $windowsPrincipal.IsInRole("Administrators") -eq $false [](start = 12, length = 71)

we have a new allowed tag: RequireAdminOnWindows which is applicable to a Describe block
the test below can be moved to it's own describe block and tagged with RequireAdminOnWindows
(see New-Item.Tests.ps1)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to keep the logically similar tests in the same describe block, that's why I used $SkipNotAdmin instead of RequireAdminOnWindows.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test architecture is that tests which require admin will only be run if the tag is proper. This test has to be tagged properly or it won't ever be run. Because of that, you need to put it in it's own Describe block, even if it does not make sense logically

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created another describe block to accomodate the test which require admin privileges.

@charub
Charu Bassi (charub) force-pushed the 2206 branch 4 times, most recently from a06b87d to 5980c1b Compare October 21, 2016 23:55

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether set-content -passthru actually retrieves the data from the file - would an explicit call to get-content be better?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing passthru and retrieving the content using get-content cmdlet

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Describe [](start = 0, length = 8)

thanks!

Resolving PowerShell#2206

Set-Content fails to create a file for PSDrive path, if the path root
begins with defaultPathSeperatorString (ex: UNC path and paths in Single
rooted filesystems like Unix)
@JamesWTruher

Copy link
Copy Markdown
Collaborator

:shipit:

@msftclas

Hi Charu Bassi (@charub), I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (Charu Bassi). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.

TTYL, MSBOT;

@daxian-dbw

Copy link
Copy Markdown
Member

close and re-open to trigger the CIs.

@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit ee2feaa into PowerShell:master Oct 28, 2016
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
Resolving PowerShell#2206

Set-Content fails to create a file for PSDrive path, if the path root
begins with defaultPathSeperatorString (ex: UNC path and paths in Single
rooted filesystems like Unix)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants