I am using the remove-profile script from here http://gallery.technet.microsoft.com/scriptcenter/Remove-Profile-787d9188 to remove profiles which is working great until an interesting problem I came across is not letting me remove a profile. When a profile is created by a user logging in with Enter-PSSession the profile cannot be removed until the winrm service is stopped. Does anyone know what causes this or know how to get around this so I don't have to stop the winrm service? Here is a screenshot of what it looks like - https://i.stack.imgur.com/rBnQ0.jpg
Asked
Active
Viewed 244 times
0
-
Do these users close the ps session by exit, Exit-PSSession, Remove-PSSession or does the session still exists? Also note there is an IdleTimeout – Lars Truijens Apr 06 '14 at 12:43
-
The session is closed by closing the cmd/PowerShell console. This is some kind of file lock problem or problem with the session still being active. Get-PSSession does not seem to work so I don't know how to view active sessions. – John Smithman Apr 06 '14 at 15:54
1 Answers
0
The PowerShell remote session were probably not closed correctly. Either make sure they are closed correctly (Remove-PSSession or Exit-PSSession) or try to remove them with something like below (PowerShell v3 and higher, see here).
Get-PSSession -ComputerName MyServerName | Remove-PSSession

Community
- 1
- 1

Lars Truijens
- 42,837
- 6
- 126
- 143
-
Get-PSSession never seems to work? it never displays any sessions information. – John Smithman Apr 06 '14 at 20:33
-
Do you use PowerShell version 3 or higher? Please check with $PSVersionTable – Lars Truijens Apr 06 '14 at 21:28
-
No, I use the default PS that comes in Windows. I think it is still 2.0? – John Smithman Apr 06 '14 at 21:48
-
You need PowerShell v3 to have that line working as expected. Different Windows versions come with different PowerShell versions. Check $PSVersionTable – Lars Truijens Apr 06 '14 at 21:51
-
The get-pssession commands are there but they just don't work? Anyways, this script/program I am working on needs to work on any version of PS so people do not need to install anything when they go to run it. I want it to work "out of the box" for people. So, what are my options to resolve this problem now? – John Smithman Apr 06 '14 at 21:55