automation
5 TopicsPowerShell doens't run correctly from scheduled task Job
Hi All, I'm trying to schedule a job in task scheduler which has a powershell code and needs to run on every wednesday to get the share point online calendar to get updated. Below is the code I've written to connect to the On prem sharepoint site, retrieve all the details and get it updated to SharePoint Online calendar site. # Install the SharePoint PnP PowerShell <module if not already installed> # Install-Module -Name PnP.PowerShell -Force -AllowClobber #Install-Module -Name PnP.Powershell Import-Module "C:\Users\pnp_3.29\SharePointPnPPowerShellOnline.psd1" -DisableNameChecking # Connect to the SharePoint site $siteUrl = "<URL>" $siteUrlDestination = "<URL>" # Specify Calendar list name $listName = "Calendar" $listNameDestination = "CalenderNew" $ResultColl = @() $cred = Import-Clixml -Path "C:\Users\creds.xml" Connect-PnPOnline -Url $siteUrl -Credentials $cred # Retrieve items from the Calendar list $calendarData = Get-PnPListItem -List $listName #Get All Field Values from the List Item $FieldValuescol = $calendarData.FieldValues foreach ($FieldValues in $FieldValuescol) { $Result = new-object PSObject $Result | add-member -membertype NoteProperty -name "Title" -Value $FieldValues.Title $Result | add-member -membertype NoteProperty -name "Type Of Leave" -Value $FieldValues.Type_x0020_Of_x0020_Leave $Result | add-member -membertype NoteProperty -name "All Day Event" -Value $FieldValues.fAllDayEvent $Result | add-member -membertype NoteProperty -name "Start Time" -Value $FieldValues.EventDate $Result | add-member -membertype NoteProperty -name "EndTime" -Value $FieldValues.EndDate $Result | add-member -membertype NoteProperty -name "Half Day" -Value $FieldValues.Half_x0020_Day $Result | add-member -membertype NoteProperty -name "Number of Working Days" -Value $FieldValues.Number_x0020_of_x0020_Working_x0 $Result | add-member -membertype NoteProperty -name "Description" -Value $FieldValues.Description $Result | add-member -membertype NoteProperty -name "Team" -Value $FieldValues.Team $ResultColl += $Result } #$ResultColl #| Export-Csv $outputPath -NoTypeInformation # Disconnect from the SharePoint site Disconnect-PnPOnline #Destination Connect-PnPOnline -Url $siteUrlDestination -UseWebLogin #remove all existing items # Get all items from the list $items = Get-PnPListItem -List $listNameDestination # Loop through each item and delete it foreach ($item in $items) { Remove-PnPListItem -List $listNameDestination -Identity $item.Id -Force } #refresh the list foreach ($res in $ResultColl) { $itemProperties = @{ Title = $res.Title Type_x0020_Of_x0020_Leave = $res.'Type Of Leave' fAllDayEvent = $res.'All Day Event' EventDate = $res.'Start Time' EndDate = $res.'EndTime' Half_x0020_Day = $res.'Half Day' Number_x0020_of_x0020_Working_x0 = $res.'Number of Working Days' Description = $res.Description Team = $res.Team } Add-PnPListItem -List $listNameDestination -Values $itemProperties } Disconnect-PnPOnline Microsoft Windows 10 Enterprise Scheduled Task - Program/Script: powershell.exe Arguments: –Noninteractive –Noprofile –Command "& {C:\Users\usernameLeave_extraction_script.ps1'}" Run whether user is logged on or not (have tried this both ways) Scheudule task doesn't run correctly even when a user is logged in and we force the task to run. Script runs perfectly when we manually run it. And doesn't display any error, the job gets starts and closes immediately.Solved2.8KViews0likes12CommentsHow to automate adding tags to multiple team members at once using PowerShell
I see that there is no way to ease the job of adding a tag to multiple users at the same time without having to look for the user in the edit tag window, so if you have a large list of team members and you want to add the tag to a lot of them or all, it is a little tedious, so exploring the API we can do this, sharing here in case anyone needs this https://get-itips.capazero.net/posts/Add-TagsToUsers2.6KViews1like1CommentAutomating Daily Task
Hello, I am new to PowerShell and want to try using it to semi-automate a repetitive task. Any help would be greatly appreciated. I need to open multiple websites (10+) in IE (not updated yet), they also all have acknowledgement popups. They need to open in individual tabs. I am trying to set up an easy way for someone to verify the sites are up and running daily. 1. What I would like to do is have PowerShell open each site from a text file (list) in its own tab. 2. In the same session. 3. Automatically click the OK on the acknowledgement popup. 4. If the site fails to open display the error in the tab. And if this is not possible can a GUI be created in PowerShell, that lets you select each site, open them in the same session on a different tab? I am trying to do this so anyone can perform this task.1.5KViews0likes3CommentsAzure diagnostics settings report
Hi I need to get report that all diagnostics settings which are configured for azure resource groups and which OMS workspace it is currently configured. List of resources and resource groups count is High. Is there any sample PowerShell script available to generate the report with include all diagnostics settings which are configured for azure resource groups with respective OMS workspace? Thanks Suri589Views0likes0CommentsInvoke-Command is not helping me anymore..
Team , I need a solution here , I am trying to connect my VM which is running in Hyper-V and I would like to deploy some of the scripts which will run automatically inside the VM and then it will create a text file which I would like to export it to the base machine . I was trying the same with Invoke-Command . I don't know the other work around . Need your help to get this thing done ASAP . Regards , Manas Saha1.5KViews0likes2Comments