-
Posts
149 -
Joined
-
Last visited
Content Type
Forums
News
20th
EduGeek EDIT Conference
Blogs
Everything posted by MartinByard
-
POWERSHELL - Change AD attribute (ScriptPath) for certain users.
MartinByard replied to Koldov's topic in Scripts
Just remove the -WhatIf bit, there is no 'do it' command -
POWERSHELL - Change AD attribute (ScriptPath) for certain users.
MartinByard replied to Koldov's topic in Scripts
Just quickly: $Users = Get-ADUser -Filter * -SearchBase "DC=mydomain,DC=com" -Properties DisplayName, scriptPath ForEach ($User in $Users) { if($User.scriptPath -like "*pavlog.bat*"){ $ScriptPath = $User.scriptPath -replace 'pavlog.bat','' Set-ADUser -Identity $User -ScriptPath $ScriptPath -WhatIf } } It checks to see if pavlog.bat is in the scriptpath, before it runs the bit of code you already had to replace and set the new scriptpath. Does that seem workable? -
Obduction and Offworld Trading Company are the free games this week on the Epic Games Store https://www.epicgames.com/store/en-US/p/obduction https://www.epicgames.com/store/en-US/p/offworld-trading-company
-
The only comment I'd make is whether or not you actually want the "Files Syncing" bit - we've disabled it as we want people to use OneDrive as their cloud filestore, also there were a few concerns raised over GDPR and the location of the cloud store (at the time it was all going to America, and there was no ability to keep it in europe - I don't know if this has changed since though).
-
From what I understood, you needed the distribute license if you were going to be hosting the installers on your own servers for people to download and then install Acrobat on their own kit. If you were using SCCM (MECM now) or some other software deployment tool and making it available for self service install from a managed portal (or force installing it everywhere) then you didn't need a license.
-
if you are going the Microsoft route for MFA, and also getting their self service password reset offering up and running, then using this bit of powershell (or GPO to put the reg key in place, or however you fancy it) will enable access to the SSPR service from the windows login screen: if(!(Test-Path HKLM:\Software\Policies\Microsoft\AzureADAccount)){ New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\AzureADAccount } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\AzureADAccount -Name "AllowPasswordReset" -PropertyType DWORD -Value "1" -Force For further info see MS's page on it https://docs.microsoft.com/en-us/azure/active-directory/authentication/howto-sspr-windows
-
Win a Western Digital 1TB MyPassport portable drive
MartinByard replied to VeryPC's topic in Our Advertisers
Me please! -
Failry useful powershell function to find installation strings (and uninstall strings) for any software that stores its data in the standard location it should go in (though i'm sure we all know of some software that doesn't), and an example of how we use it to uninstall software when you might not know the msi code or have the original msi to use: function Get-Uninstaller { [CmdletBinding()] param( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $Name ) $local_key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' $machine_key32 = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*' $machine_key64 = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' $keys = @($local_key, $machine_key32, $machine_key64) Get-ItemProperty -Path $keys -ErrorAction 'SilentlyContinue' | ?{ ($_.DisplayName -like "*$Name*") -or ($_.PsChildName -like "*$Name*") } | Select-Object PsPath,DisplayVersion,DisplayName,UninstallString,InstallSource,InstallLocation,QuietUninstallString,InstallDate } ## end of function # Find all the uninstallers for the named piece of software $uninstallers = Get-Uninstaller ADSelfService # For each uninstaller found, run msiexec /x against it ForEach($uninstaller in $uninstallers){ $MSIGuid = Split-Path -leaf $uninstaller.PSPath Start-Process "Msiexec.exe" -ArgumentList "/x $MSIGuid /qn" -Wait }
-
Might be worth making sure everything is running on uptodate clients, incase something has snuck into a later one that isnt supported by earlier versions ?
-
Windows 10 Teams/Other MS Cloud Services Error - WAM 80080300
MartinByard replied to petben's topic in Cloud Services
We've got a few machines with this issue as well (all 1909) and the MS recommendation we saw was several reboots after installing the update can resolve it - seems to have worked for us so far ... but your mileage may vary. -
Add A Local User In An SCCM/MECM Task Sequence
MartinByard replied to Fazza's topic in Enterprise Software
We do ours in a powershell script (which also does other things at the same time), and our code is: net.exe user /add "UserName" "Password" /fullname:"UserName" /comment:"IT Services Admin Account" net.exe localgroup administrators UserName /add WMIC USERACCOUNT WHERE "Name='UserName'" SET PasswordExpires=FALSE this creates the local admin account that we use, and sets a default password (until LAPS kicks in once the machine is built and up and running and sets a new password for it). -
We've found that if you block access to powershell it has the unfortunate side effect of stopping our powershell logon scripts running ....
-
USe a batch file running on your PC (or server) that calls the scheduled task ? schtasks /Run [/s system [/u username [/P [password]]]] /TN taskname Presuming the account running a cmd prompt is admin on the remote machines, the scheduled task is called "Daily Shutdown" then the following command should run the task on the remote computer "ExamplePC" schtasks /Run /S ExamplePC /TN "Daily Shutdown" It could be awkward to create the batch file, depending on how many PCs you need to run the task on ...
-
[SCCM/MECM] Migrate endpoints from one site to another
MartinByard replied to Garacesh's topic in Enterprise Software
When we moved from our old environment to our new one, we created a package in the old one with the source files pointing to the CCM client folder (this is found at \\\SMS_\Client) and the program it ran was a custom powershell script that was: Copy-Item -Path .\New_Client -Destination C:\Windows\Temp\New_Client -Recurse -Force Start-Process C:\Windows\Temp\New_Client\ccmsetup.exe -ArgumentList "/MP:[b][/b] /skipprereq:Silverlight.exe /forceinstall /source:C:\Windows\Temp\New_Client /usepkicert SMSSITECODE=[b][/b] SMSCACHESIZE=25000" -Wait Obviously this command line can be tailored to your needs (you might not want to skip silverlight, or have PKI certs for HTTPS communications - or need a 25Gb cache). Once this has run on a client in the old environment - it pulls down and installs the client from the new environment and populates itself. -
Only other suggestion I've got off the top of my head, is it's not able to run the specific screensaver you're trying to get it use (most likely due to not finding the file specified). Try specifiying a different screensaver, or try fully qualifying the file path ( %windir%\system32\rundll32.exe user32.dll,LockWorkStation )
-
It's showing the User section of that GPO as being disabled .... could that be your issue (presuming you didn't disable it as it didn't seem to be working) ?
-
Something like this, run from an elevated powershell prompt ? it should capture a list of all the folders that match your criteria in the $ListOfFolders variable, and then they can be piped individually to a delete command $BaseDir = "C:\Users" $NameToFind = "OneDrive - eLearning & Information Management\tempsimsrpt" $ListOfFolders = Get-ChildItem $BaseDir -Recurse | Where-Object { $_.PSIsContainer -and $_.FullName -like "*$NameToFind"} foreach($FolderToDelete in $ListOfFolders) { $FolderToDelete.FullName #Remove-Item -Path $FolderToDelete.FullName -Recurse -Force #RMDIR /S /Q $FolderToDelete.FullName } Run it once as is to list all the folders it wants to delete, then all you need to do is remove the hash in front of the command you want to use to actually carry out the delete. I would advise testing it on one machine with not many users first (maybe after making a backup) just in case it goes wrong.
- 1 reply
-
- cmd
- command line
-
(and 1 more)
Tagged with:
-
The PS cmdlets are built in and get installed when you install the sccm console on a machine - so we just run them from our managment VM. The ones you want to concentrate on are Export-CMApplication and Export-CMPackage There are also corresponding cmdlets for task sequences, baseline configs, device collections (possibly more, but those are the ones we concentrated on). As an example, here is how we use them in our scheduled task: Export_All_Apps.ps1 Param( [parameter( Position = 0, Mandatory=$true ) ] [Alias("SMS")] [ValidateScript({ $ping = New-Object System.Net.NetworkInformation.Ping $ping.Send("$_", 5000)})] [ValidateNotNullOrEmpty()] [string]$SMSProvider="", [parameter( Position = 1, Mandatory = $true ) ] [string]$ExportFolder ) Function Get-SiteCode { $wqlQuery = “SELECT * FROM SMS_ProviderLocation” $a = Get-WmiObject -Query $wqlQuery -Namespace “root\sms” -ComputerName $SMSProvider $a | ForEach-Object { if($_.ProviderForLocalSite) { $script:SiteCode = $_.SiteCode } } return $SiteCode } $SiteCode = Get-SiteCode #Import the CM12 Powershell cmdlets if (-not (Test-Path -Path $SiteCode)) { Write-Verbose "CM12 module has not been imported yet, will import it now." Import-Module ($env:SMS_ADMIN_UI_PATH.Substring(0,$env:SMS_ADMIN_UI_PATH.Length – 5) + '\ConfigurationManager.psd1') | Out-Null } #CM12 cmdlets need to be run from the CM12 drive Set-Location "$($SiteCode):" | Out-Null if (-not (Get-PSDrive -Name $SiteCode)) { Write-Error "There was a problem loading the Configuration Manager powershell module and accessing the site's PSDrive." exit 1 } $Apps = Get-CMApplication foreach ($App in $Apps) { $AppFileName = $App.LocalizedDisplayName -replace ("/","_") #Export-CMApplication -OmitContent -Path "$(Join-Path $ExportFolder $($App.LocalizedDisplayName)).zip" -ID $($App.CI_ID) -Force Export-CMApplication -OmitContent -Path "$(Join-Path $ExportFolder $($AppFileName)).zip" -ID $($App.CI_ID) -Force } Export_All_Packages.ps1 Param( [parameter( Position = 0, Mandatory=$true ) ] [Alias("SMS")] [ValidateScript({ $ping = New-Object System.Net.NetworkInformation.Ping $ping.Send("$_", 5000)})] [ValidateNotNullOrEmpty()] [string]$SMSProvider="", [parameter( Position = 1, Mandatory = $true ) ] [string]$ExportFolder ) Function Get-SiteCode { $wqlQuery = “SELECT * FROM SMS_ProviderLocation” $a = Get-WmiObject -Query $wqlQuery -Namespace “root\sms” -ComputerName $SMSProvider $a | ForEach-Object { if($_.ProviderForLocalSite) { $script:SiteCode = $_.SiteCode } } return $SiteCode } $SiteCode = Get-SiteCode #Import the CM12 Powershell cmdlets if (-not (Test-Path -Path $SiteCode)) { Write-Verbose "CM12 module has not been imported yet, will import it now." Import-Module ($env:SMS_ADMIN_UI_PATH.Substring(0,$env:SMS_ADMIN_UI_PATH.Length – 5) + '\ConfigurationManager.psd1') | Out-Null } #CM12 cmdlets need to be run from the CM12 drive Set-Location "$($SiteCode):" | Out-Null if (-not (Get-PSDrive -Name $SiteCode)) { Write-Error "There was a problem loading the Configuration Manager powershell module and accessing the site's PSDrive." exit 1 } $Packages = Get-CMPackage -fast foreach ($Package in $Packages) { write-host working on $Package.Name Export-CMPackage -WithContent $FALSE -ExportFilePath "$(Join-Path $ExportFolder $($Package.Name)).zip" -ID $($Package.PackageID) } Apps_Backup.ps1 $DT = Get-Date -Format yyyy_MM_dd Start-Transcript -Path E:\Scripts\Applications_Backup\$DT.txt &\Export_All_Apps.ps1 -SMSProvider FQDN.Of.SCCM.Server -ExportFolder -Verbose &\Export_All_Packages.ps1 -SMSProvider FQDN.Of.SCCM.Server -ExportFolder -Verbose this will generate a folder full of zip files, that can be imported to the new environment either in a scripted en mass fashion, or individually.
-
When we recently migrated our SCCM server onto new hardware, we took the opportunity to build it up again from new so that we didnt have legacy data hanging around - but chose to export the apps / packages / tasksequences / query based device collections that were still relevant from the old environment to the new. This can be done relatively easily just right clicking on the desired object and choosing export from the menu. There are also built in powershell cmdlets for exporting all of these that can be used (we've got weekly sheduled tasks that do this, as one form of DR).
-
I'm in and working on most things, but accessing files through teams is hit and miss (with more misses than hits).
-
Transfer IIS config on Server Upgrade
MartinByard replied to TechMonkey's topic in Windows Server 2019
The site i found it on was transferring iis 7.5 to 10, so its possible MS haven't updated the documentation for it .. https://www.assistanz.com/steps-to-migrate-the-websites-from-iis-7-5-to-iis-10/ -
Transfer IIS config on Server Upgrade
MartinByard replied to TechMonkey's topic in Windows Server 2019
A quick google suggests MS's Web Deploy application might be able to do the job. https://www.microsoft.com/en-us/download/details.aspx?id=39277
