powershell
335 TopicsPowershell script to enable inheritance for the folders created in NTFS share
Hi, We have a NTFS Share folder wherein we are creating all the users' homeDirectories (homefolder) within the enterprise using Oracle identity management tool. Homefolder creation is working good. But, we are having issues with the permissions. -- It doesn't inherit permissions from the parent folder. -- sometimes the owner also doesn't get the permissions. Is there a way for us to check the current permissions and enable inheritance for the folders created in the share and all the child items within. We have a lot of homefolders and not able to figureout how to do it via Powershell. Any input will be greatly appreciated. Thanks in advance.Solved92KViews0likes13CommentsStore password in Windows credential manager and use it in Powershell
On the #ESPC16 in Vienna someone is showing a way to store credentials in the Windows credential manager and then use is in Powershell to connect to Exchange / SharePoint / Azure… online. It was a very simple and I will use it for some scheduled tasks. But i don’t remember how he does it and I didn’t find such a good and simple way in the net. Anyone has it also seen or use it before?Solved79KViews2likes8CommentsFailed downloading Az and other modules for powershell
Hello, I am attempting to install the Az module for powershell. I haven't had issues in the past but now I get errors when trying to do so and I have tried many ways to do this. It seems like an issue on the powershellgallery site but I am not 100% sure. Here's my situation On the machine as an administrator Running powershell.exe as an adminsitrator Attempting this on a client server and a local server (where I previously was able to do this) so does NOT appear to be proxy, firewall or security related in any way I click yes to run from untrusted repository (always have, never been an issue) I receive the follow error: WARNING: Source Location 'https://www.powershellgallery.com/api/v2/package/Az.Accounts/1.7.4' is not valid. PackageManagement\Install-Package : Package 'Az.Accounts' failed to download. At C:\Program Files\WindowsPowershell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21 + ... $null = PackageManagement\Install-Package @PSBoundParameters + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ResourceUnavailable: (C:\Users\{username}....Accounts.nupkg:String) [Install-Package], Exception + FullyQualifiedErrorId : PackageFailedInstallOrDownload,Microsoft.Powershell.PackageManagement.Cmdlets.InstallPackage I have attempted many of the switches -Force -AllowClobber etc ... attempted to install by downloading locally but not sure I am doing that right as it doesn't seem to work with the instructions I have found around the web. This started sometime last week, perhaps Thursday. I'm at a loss, been trying this for way too long. Any insight? Thanks ahead of time! SSolved61KViews1like14CommentsWindows 10 Delete User Profiles Older Than 60 Days
Hi. I am working on trying to automate cleaning up local user profiles on some machines that after awhile run into HDD space issues. I've been working on a script below for this, but I cannot get it to work quite right. I want to leave any profile that does not have a creation date older than 30 days. But it still deletes all profiles in the C:\Users folder. It doesn't seem to recognize the CreationTime on the profile, even though I can visually verify the date is within 30 days. $Results = Get-CimInstance -Class Win32_UserProfile | Where-Object { $_.CreationTime -lt (Get-Date).AddDays(-30) -and $_.Name -ne "Public" -and $_.Name -ne "defaultuser0" -and $_.LocalPath -like "C:\Users\*"} Foreach ($Temp in $Results) { $temp | Remove-CimInstance Remove-Item -Path $temp.localpath -Recurse -force }60KViews0likes4CommentsGUI form front-end for Powershell
Looking for a (free?) GUI form frontend for scripts that I want to distribute to users. Basically, I want to gather three or four data points.... such as first name, lastname, domain name, and country in a GUI form, which then passes these to parameters or variables in the Powershell script. As a bonus it would be great to be able to display results within the form, such as a message, "successfully submitted" or the like. Shouldn't a PowerApp or another technology within Office 365 be able to do this? Thanks. --- Larry59KViews0likes8CommentsMicrosoft.IdentityModel.Clients.ActiveDirectory could not load
Hi So i'm getting this error in my PowerShell logs and i can't find a way to resolve it. 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.13.9.1126, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. Can I get any help? Thanks53KViews0likes7CommentsCannot dot-source this command because it was defined in a different language mode.
Microsoft.PowerShell_profile.ps1: Cannot dot-source this command because it was defined in a different language mode. To invoke this command without importing its contents, omit the '.' operator. I am getting this error when I open my PowerShell anywhere... I have few scripts present in my PS Profile, but this is failing with error, and I can't import, its blocking me to even set a property. $Host.Name = 'Test' InvalidOperation: Cannot set property. Property setting is supported only on core types in this language mode. Can someone please help me to get rid of this issue. Thanks!37KViews0likes12CommentsPowerShell script and Window Focus
I have a script that worked under Windows 10 1903. It does not work under Windows 10 1909. I'm hoping someone here can shed some light on what is happening and maybe suggest a workaround. I'm using Zoom for online classes and found that if I get busy working in another window and get asked a question, it normally takes a few seconds to find the proper Zoom window so I can unmute my microphone and answer. I came up with a solution to use an application called Touch Portal which allows me to run a script that brings the proper Zoom window into focus by simply pressing a button in the Touch Portal interface. This worked well in Windows 10 1903. However, in 1909 the Zoom icon in the taskbar simply starts flashing and does not bring the window into focus. I have confirmed that the script does work in a PowerShell console in 1909; it just doesn't fully work when pressing the Touch Portal button. I have included the script below. I'm assuming the change occurred to prevent rogue applications from stealing window focus. Just hoping there is some kind of work around to allow it to work again. (The bulk of the script came from here.) #requires -Version 2 function Show-Process($Process, [Switch]$Maximize) { $sig = ' [DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); [DllImport("user32.dll")] public static extern int SetForegroundWindow(IntPtr hwnd); ' if ($Maximize) { $Mode = 3 } else { $Mode = 4 } $type = Add-Type -MemberDefinition $sig -Name WindowAPI -PassThru $hwnd = $process.MainWindowHandle $null = $type::ShowWindowAsync($hwnd, $Mode) $null = $type::SetForegroundWindow($hwnd) } $ZoomTime = Get-Process Zoom | select id, starttime If ($ZoomTime[0].starttime -gt $ZoomTime[1].starttime) { $ZoomPID = $ZoomTime[0].id } else { $ZoomPID = $ZoomTime[1].id } Show-Process -Process (Get-Process -ID $ZoomPID)34KViews0likes3CommentsConvert a text string to a correct date time format
Hello folks, I have maybe a simple question for the experienced people around here 🙂 . I have a runbook in azure that is getting the field "CreatedDateTime" of a unified group (Teams Team). The format of this field ist like the following "2020-08-06T06:03:19Z". This is not recognized as a valid DateTime format by the cmdlet: $DateTime=[Datetime]::ParseExact($DateTime, 'MM/dd/yyyy', $null) Can anyone point me to a solution how to get the string "2020-08-06T06:03:19Z" into a string like "2020-08-06" or "06-08-2020". Every hint is appreciated. Thank you all 😉Solved34KViews0likes4Comments